NodeEditor adding TextInput
-
Hi,
I found a project on internet about node editor which is used QGraphicsScene. and I'm new on this. I need to add a TextInput on the window(which is in the picture) to be able to take values from user. But I don't know how to do. Do you have any idea? Ty. -
Hi,
I found a project on internet about node editor which is used QGraphicsScene. and I'm new on this. I need to add a TextInput on the window(which is in the picture) to be able to take values from user. But I don't know how to do. Do you have any idea? Ty.@Yunus
For a "TextInput" you can use Qt widgets likeQLineEdit
on your scene. You can addQWidget
s via http://doc.qt.io/qt-5/qgraphicsscene.html#addWidget, which wraps them in a "graphics proxy widget" http://doc.qt.io/qt-5/qgraphicsproxywidget.html. -
@JonB
Ty you for ur reply JonB. But can you give an example how to do that. I added a QWidget to my app as you said but the rest is complex for me. -
@JonB
When I look into your link carefully, I found the solution. Thank u very much for ur help. Here is the solution:scene = new QGraphicsScene(this);
QLineEdit *edit = new QLineEdit; QGraphicsProxyWidget *proxy = scene->addWidget(edit); edit->isVisible(); proxy->isVisible();
-
@JonB
When I look into your link carefully, I found the solution. Thank u very much for ur help. Here is the solution:scene = new QGraphicsScene(this);
QLineEdit *edit = new QLineEdit; QGraphicsProxyWidget *proxy = scene->addWidget(edit); edit->isVisible(); proxy->isVisible();
@Yunus
Hi
Yes, simply give the widget to the proxy and insert proxy into scene.
If you later find out you want to move them by mouse and have issues, please see here
https://stackoverflow.com/questions/15413564/make-qgraphicsproxywidget-movable-selectable -
Hi
Small note.
This sample also has a text object that is not based on proxy
http://doc.qt.io/qt-5/qtwidgets-graphicsview-diagramscene-example.html
(it uses QGraphicsTextItem )