PDA

View Full Version : QGraphicsTextItem setPlainText() is resetting the item



Caolan O'Domhnaill
24th November 2015, 21:29
Hello all,

I have managed to do a lot of work on the application I am working on after an initial ramp-up period and I have run into a confusing problem.

I have as QTableView class that allows the user to type in text into a QDelegate'ed QTableWidgetItem. There is a SIGNAL/SLOT combo that calls QGraphicsTextItem::setPlainText() directly onto a QGraphicsTextItem control I have created.

The QGraphicsTextItem control is a child object to another QGraphicsItem, and both have been registered with the scene that is attached to the primary widget in the application.

The problem is that when I make the QGraphicsTextItem::setPlainText() call with some new text, all of the text in the item disappears.

I found a potential solution here: http://stackoverflow.com/questions/3789909/updating-a-qgraphicstextitem-on-text-change

However that actually made the entire control disappear rather than make the text go away. I can select the empty control but I can no longer double-click in it and set the text that way like I could before the call.

Any ideas?

Cheers!
-Caolan.

Caolan O'Domhnaill
25th November 2015, 23:19
bueller? bueller?

d_stranz
26th November 2015, 01:09
The problem is that when I make the QGraphicsTextItem::setPlainText() call with some new text, all of the text in the item disappears.

Including the new text? You are going to have to post the code (all of the code in the slot, not just the setPlainText() line) so we can see some context.

Caolan O'Domhnaill
28th November 2015, 07:13
I solved the problem actually. It revolved around catching a bug I wasn't expecting...

Thanks!