Qt-interest Archive, May 2007
Bug with QGraphicsTextItem ?
Message 1 in thread
Hi,
I put a QGraphicsTextItem in a view as movable.
On Double-click it becomes editable.
OnMousePress, if it is not a double click, and if it is editable, I make
it as NoTextInteraction.
Still I am not able to move the textItem.
Is it a QT bug or I am doing something wrong ?
Attached is the code, may have some redundancy as I have been trying out
various things.
ConnectorText is a class derived from QGraphicsTextItem, with only these
two handlers overridden.
void ConnectorText::mouseDoubleClickEvent ( QGraphicsSceneMouseEvent *
event )
{
m_bIsDblClk = true;
if(textInteractionFlags() != Qt::TextEditable)
setTextInteractionFlags(Qt::TextEditable);
QGraphicsTextItem::mouseDoubleClickEvent(event);
m_bIsDblClk = false ;
}
void ConnectorText::mousePressEvent ( QGraphicsSceneMouseEvent * event )
{
int tmp = textInteractionFlags();
if(m_bIsDblClk == false && textInteractionFlags() !=
Qt::NoTextInteraction)
{
setTextInteractionFlags(Qt::NoTextInteraction);
setFlag(QGraphicsItem::ItemIsMovable);
}
QGraphicsTextItem::mousePressEvent(event);
}
Thanx in advance
--Prateek
Message 2 in thread
No replies to this query :-(
Have I not been able to express the problem clearly or no-one has
experienced a similar problem ?
________________________________
From: Prateek Tiwari [mailto:ptiwari@xxxxxxxxxxx]
Sent: Monday, May 14, 2007 2:51 PM
To: qtForum
Subject: Bug with QGraphicsTextItem ?
Hi,
I put a QGraphicsTextItem in a view as movable.
On Double-click it becomes editable.
OnMousePress, if it is not a double click, and if it is
editable, I make it as NoTextInteraction.
Still I am not able to move the textItem.
Is it a QT bug or I am doing something wrong ?
Attached is the code, may have some redundancy as I have been
trying out various things.
ConnectorText is a class derived from QGraphicsTextItem, with
only these two handlers overridden.
void ConnectorText::mouseDoubleClickEvent (
QGraphicsSceneMouseEvent * event )
{
m_bIsDblClk = true;
if(textInteractionFlags() != Qt::TextEditable)
setTextInteractionFlags(Qt::TextEditable);
QGraphicsTextItem::mouseDoubleClickEvent(event);
m_bIsDblClk = false ;
}
void ConnectorText::mousePressEvent ( QGraphicsSceneMouseEvent *
event )
{
int tmp = textInteractionFlags();
if(m_bIsDblClk == false && textInteractionFlags() !=
Qt::NoTextInteraction)
{
setTextInteractionFlags(Qt::NoTextInteraction);
setFlag(QGraphicsItem::ItemIsMovable);
}
QGraphicsTextItem::mousePressEvent(event);
}
Thanx in advance
--Prateek