PDA

View Full Version : QUndoCommand and QGraphicsTextItem



airglide
17th December 2012, 16:36
Hello everyone,

I wanted to implement costom behvior for typing in a QGraphicsTextItem. The Problem is, that I've a MainWindow class where the QUndoStack is (and where it should be added). Is there a good way to connect the active QGraphicsTextItem with this method(on Mainwindow class which creates a QUndoCommand for typing) or do I have to emit a singal from the QGraphicsScene if the QGraphicsTextitem has changed?

hope someone can help me ;)

thank you

airglide

airglide
17th December 2012, 19:08
well I've managed to do it, it isn't that pretty...

If I add an QTextItem a QUndoCommand is created and there i can call a QGraphicsScene public method which emits a Signal to the MainWindow, where the new QGraphicsTextItem is connected/disconnected...

if you find out a smoother solution let me know ;)

wysota
17th December 2012, 20:23
QGraphicsTextItem has an embedded QTextDocument. You can manipulate it directly without interfacing the scene.