Qt-interest Archive, April 2007
setFlag for QGraphicsItem
Message 1 in thread
Hi,
I can make a QItemTextRect editable by
setFlag(QtGraphicsItem::ItemIsEditable),
but how do I make it uneditable once it is has been made editable ?
What I am trying to achive is this :-
I have a QGraphicsTextItem. It is both editable and movable. Since it is
editable, everytime i click on it,
it becomes editable and I cannot move it. So I want to make it editable
only on a double click and when it is not in focus, I want it
to be non-editable, so that user can move this item.
Is there a better way to approach this issue ?
Thnx in advance
--Prateek
Message 2 in thread
On 27.04.07 16:36:43, Prateek Tiwari wrote:
> I can make a QItemTextRect editable by
> setFlag(QtGraphicsItem::ItemIsEditable),
> but how do I make it uneditable once it is has been made editable ?
By using the same function and the 2nd argument to it.
Andreas
--
[ signature omitted ]
Message 3 in thread
Yeah, I have tried this, but dosent seem to work.
Below is my class.
What I want to do is to make it(TextItem) editable on double click and
make it selectable and movable on single click and drag.
The problem is, the first time I am able to move the Texttem, but after
that It does not move in the view.
I have tried various values for TextInteraction flag :(.
It works if I comment out lines A and B.
Would someone advise me what am I doing wrong ?
--Prateek
//Header
class ConnectorText : public QGraphicsTextItem
{
protected:
virtual void mousePressEvent(QGraphicsSceneMouseEvent *);
virtual void mouseDoubleClickEvent ( QGraphicsSceneMouseEvent *
event );
public:
ConnectorText(const QString& str, QGraphicsItem *parent);
};
//.cpp
void ConnectorText::mouseDoubleClickEvent ( QGraphicsSceneMouseEvent *
event )
{
setTextInteractionFlags(Qt::TextEditable); // Line A
QGraphicsTextItem::mouseDoubleClickEvent(event);
}
void ConnectorText::mousePressEvent ( QGraphicsSceneMouseEvent * event )
{
setTextInteractionFlags(Qt::NoTextInteraction); // Line B
QGraphicsTextItem::mousePressEvent(event);
}
ConnectorText::ConnectorText(const QString &str, QGraphicsItem *parent)
: QGraphicsTextItem(str,parent)
{
setFlag(QGraphicsItem::ItemIsMovable);
setFlag(QGraphicsItem::ItemIsSelectable);
}
-----Original Message-----
From: Andreas Pakulat [mailto:apaku@xxxxxx]
Sent: Friday, April 27, 2007 5:13 PM
To: qt-interest@xxxxxxxxxxxxx
Subject: Re: setFlag for QGraphicsItem
On 27.04.07 16:36:43, Prateek Tiwari wrote:
> I can make a QItemTextRect editable by
> setFlag(QtGraphicsItem::ItemIsEditable),
> but how do I make it uneditable once it is has been made editable ?
By using the same function and the 2nd argument to it.
Andreas
--
[ signature omitted ]
Message 4 in thread
Can Anyone help me understand what I am doing wrong here and why is my
textitem not moving ?
Thnx
Parteek
________________________________
From: Prateek Tiwari [mailto:ptiwari@xxxxxxxxxxx]
Sent: Sunday, April 29, 2007 1:01 PM
To: Andreas Pakulat; qt-interest@xxxxxxxxxxxxx
Subject: RE: setFlag for QGraphicsItem
Yeah, I have tried this, but dosent seem to work.
Below is my class.
What I want to do is to make it(TextItem) editable on double
click and make it selectable and movable on single click and drag.
The problem is, the first time I am able to move the Texttem,
but after that It does not move in the view.
I have tried various values for TextInteraction flag :(.
It works if I comment out lines A and B.
Would someone advise me what am I doing wrong ?
--Prateek
//Header
class ConnectorText : public QGraphicsTextItem
{
protected:
virtual void mousePressEvent(QGraphicsSceneMouseEvent
*);
virtual void mouseDoubleClickEvent (
QGraphicsSceneMouseEvent * event );
public:
ConnectorText(const QString& str, QGraphicsItem
*parent);
};
//.cpp
void ConnectorText::mouseDoubleClickEvent (
QGraphicsSceneMouseEvent * event )
{
setTextInteractionFlags(Qt::TextEditable); // Line A
QGraphicsTextItem::mouseDoubleClickEvent(event);
}
void ConnectorText::mousePressEvent ( QGraphicsSceneMouseEvent *
event )
{
setTextInteractionFlags(Qt::NoTextInteraction); // Line
B
QGraphicsTextItem::mousePressEvent(event);
}
ConnectorText::ConnectorText(const QString &str, QGraphicsItem
*parent) : QGraphicsTextItem(str,parent)
{
setFlag(QGraphicsItem::ItemIsMovable);
setFlag(QGraphicsItem::ItemIsSelectable);
}
-----Original Message-----
From: Andreas Pakulat [mailto:apaku@xxxxxx <mailto:apaku@xxxxxx>
]
Sent: Friday, April 27, 2007 5:13 PM
To: qt-interest@xxxxxxxxxxxxx
Subject: Re: setFlag for QGraphicsItem
On 27.04.07 16:36:43, Prateek Tiwari wrote:
> I can make a QItemTextRect editable by
> setFlag(QtGraphicsItem::ItemIsEditable),
> but how do I make it uneditable once it is has been made
editable ?
By using the same function and the 2nd argument to it.
Andreas
--
Your true value depends entirely on what you are compared with.
--
To unsubscribe - send a mail to
qt-interest-request@xxxxxxxxxxxxx with "unsubscribe" in the subject or
the body.
List archive and information:
http://lists.trolltech.com/qt-interest/
<http://lists.trolltech.com/qt-interest/>