PDA

View Full Version : Problem on set QGraphicsTextItem write protect.



patrik08
22nd July 2007, 20:28
I fill my QGraphicsTextItem with QTextDocument text image and all style i rotate this floating text and image like other paint. Now i like to lock the text and on qmenu , i swap QGraphicsTextItem to other flag ...
Why the parent can write inside? and paint this objekt? parent is only QGraphicsScene..!

how i can solve this?

My enum is valid and display correct¨!



/* class FloatDiagram : public QGraphicsTextItem */
/* FloatDiagram( const GenAttribute &p , QMenu *Diss , QGraphicsItem *parent, QGraphicsScene *scene ) */

void FloatDiagram::FloatLock()
{
setOpenExternalLinks(true);
setTextInteractionFlags(Qt::NoTextInteraction);
setTextInteractionFlags(Qt::LinksAccessibleByMouse );
setTextInteractionFlags(Qt::TextBrowserInteraction );
modus = MODUS_LOCK; /* enum write protect not move only click link */
}

void FloatDiagram::FloatUnLock()
{
setFlag(QGraphicsItem::ItemIsMovable, true);
setFlag(QGraphicsItem::ItemIsSelectable, true);
setTextInteractionFlags(Qt::NoTextInteraction); /* edit on double click if not lock */
modus = MODUS_MOVE; /* enum to move and edit */
}

Gopala Krishna
22nd July 2007, 20:53
This seems ok. Are you using setTextInteractionFlags anywhere else in code ?
If so do verify(if possible post) whether they are modifying the flags or not.
Also make sure the functions(FloatLock and FloatUnLock) are being called (double check this!)

BTW calling setTextIntetactionFlags multiple times doesn't have the effect you need. It just sets the flag to the value passed to the last function call. You need to use an OR combination in a single call instead of calling multiple times individually.
I mean , in your case the final value of textInteractionFlags will be Qt::TextBrowserInteraction and not combination of all three. Actually i still dont understand your intention of multiple calls.