PDA

View Full Version : Textbox



Devoraz
22nd July 2009, 07:14
Hi, the image show the yellow color node which is drawn using Qpainter. i would now like to place a textbox above the End Device. so that the user could input words on top of the End Device. anyway to do so?

Lykurg
22nd July 2009, 08:38
Hi,

fist you can use a QGraphicsView for your image and then you can easily put a QLineEdit on it

or

you positioning a line edit absolutely over your QWidget with the image. but then you have to catch move event of you widget to move the line edit with it.


And please add your images on that forum and not from 3rd part services to keep your post valid also in 2 years...

nish
22nd July 2009, 09:38
where is the image? i cant see it..

Devoraz
22nd July 2009, 11:56
can you roughly guide me what to write for the QGraphicsView command?

Lykurg
22nd July 2009, 12:47
Something like that


int main(int argc, char **argv)
{
QApplication app(argc, argv);

QGraphicsScene scene;
QGraphicsView view(&scene);

QPixmap pix(/*your generated pixmap here*/);
QGraphicsPixmapItem *pi = scene.addPixmap(pix);
// resize your scene and view to the pix bounding rect
pi->setPos(0,0);
QGraphicsProxyWidget *lineEdit_item = scene.addWidget(new QLineEdit);
// set position and hide/show it when needed
// -> QGraphicsScene::mousePressEvent() and release event...

view.show();

return app.exec();
}

Lykurg
22nd July 2009, 12:51
Is the picture size fix? if so, a more easier possibility would be: Create a QFrame of the picture size and positioning a QLineEdit inside using QSpacer and stuff. Then set your image as the background of the frame. But still for the frame you must detect the button press, but that's only 10 lines as maximum.

Devoraz
23rd July 2009, 07:37
yes what ever inside the yellow node is fix. the yellow node will move around though, but what ever inside the yellow node will move with the node i suppose. haha. QT is kind of complicated man. totally knew to this project i've got. i had learn C# and C++. but this whole c++ user QT library.

its making my life difficult. my project gonna be doom~! well. but i have changed and enchance a few things in my GUI though. just this changing of the name of the End Device is making me really headache...