PDA

View Full Version : Hiding the cursor in QGraphicsTextItem



yartiss
7th March 2008, 20:14
Hello,
I am using Qt 4.3.2 and I am having a little difficulty with QGraphicsTextItem. When the focus leaves the TextItem, the cursor still remains visible. This is a problem for me because I have multiplie TextItems on the screen, and therefore many visible cursors at the same time!

How can I hide the cursor in a QGraphicsTextItem?

Also, is there a good reference somewhere that can show me the relationships between all the elements involved in the QDocument? (QTextDocument, QTextCursor, QTextBlock, QTextLine, QTextLayout, ...)

Thank you,

-MIke

ashukla
8th March 2008, 04:34
widget->setCursor(Qt::BlankCursor)
http://www.qtcentre.org/forum/f-qt-p...dget-7818.html

aamer4yu
8th March 2008, 12:51
u can check the example in Qt Demo under Graphics View... they have made a simple diagram editor... it may help you

yartiss
13th March 2008, 13:19
Thanks for the help, but I eventually (yesterday!) found the answer.

The trick is the setTextInteractionFlags() method. When the text field loses focus you should set the flag to setTextInteractionFlags(Qt::NoTextInteraction)

And then when it regains the focus you should set it to SetTextInteractionFlags(Qt::TextEditorInteraction) or whatever other combination of flags you wish to use.

Btw, the other idea of setting the cursor to none will change the mouse cursor, not the cursor in the text.

Thanks!

-yartiss