Help required with Qt GraphicsViewTextItem

Hi!

I am really stuck up with a task relating to Qt GraphicsView. Any help or suggestions will be highly appreciated.

In my QGraphicsView application, I have a few editable QGraphicsTextItems that I have added to the scene. I need the following functionality:

- Setting validator for float so that the user does not by mistake enter a character or new line in that text item.

- Emitting a signal once the text is changed by the user.

Can anyone please suggest how I can implement this in my application? I have tried real hard but I am not able to find anything suitable. If there is any alternative or workaround, I'll be grateful to know.

Thanks!
Take a look at the documantion of QGraphicsTextItem:
http://qt-project.org/doc/qt-5.0/qtwidgets/qgraphicstextitem.html

what you need is the document():
http://qt-project.org/doc/qt-5.0/qtgui/qtextdocument.html


the QTextDocument emits a signal when it is changed (and more):
http://qt-project.org/doc/qt-5.0/qtgui/qtextdocument.html#signals

Read this to understand how to connect to a signal:
http://qt-project.org/doc/qt-5.0/qtcore/signalsandslots.html


- Setting validator for float so that the user does not by mistake enter a character or new line in that text item.
It doesn't look like that there is a validator. I wouldn't use one. Just let the user type whatever he wants to and tell him later when the data is somehow used what he did wrong if
Thank You coder777... really appreciate your help.

I didn't know about this QTextDocument element that you have suggested. Will check out the links you provided.
Topic archived. No new replies allowed.