Results 1 to 7 of 7

Thread: Textbox

  1. #1
    Join Date
    Jul 2009
    Posts
    55
    Thanks
    3

    Default Textbox

    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?
    Attached Images Attached Images
    Last edited by Devoraz; 22nd July 2009 at 10:55.

  2. #2
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Wiki edits
    5

    Default Re: Textbox

    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...

  3. #3
    Join Date
    Jun 2007
    Location
    India
    Posts
    1,042
    Thanks
    8
    Thanked 133 Times in 128 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Textbox

    where is the image? i cant see it..

  4. #4
    Join Date
    Jul 2009
    Posts
    55
    Thanks
    3

    Default Re: Textbox

    can you roughly guide me what to write for the QGraphicsView command?

  5. #5
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Wiki edits
    5

    Default Re: Textbox

    Something like that

    Qt Code:
    1. int main(int argc, char **argv)
    2. {
    3. QApplication app(argc, argv);
    4.  
    5. QGraphicsView view(&scene);
    6.  
    7. QPixmap pix(/*your generated pixmap here*/);
    8. QGraphicsPixmapItem *pi = scene.addPixmap(pix);
    9. // resize your scene and view to the pix bounding rect
    10. pi->setPos(0,0);
    11. QGraphicsProxyWidget *lineEdit_item = scene.addWidget(new QLineEdit);
    12. // set position and hide/show it when needed
    13. // -> QGraphicsScene::mousePressEvent() and release event...
    14.  
    15. view.show();
    16.  
    17. return app.exec();
    18. }
    To copy to clipboard, switch view to plain text mode 

  6. #6
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Wiki edits
    5

    Default Re: Textbox

    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.

  7. #7
    Join Date
    Jul 2009
    Posts
    55
    Thanks
    3

    Default Re: Textbox

    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...

Similar Threads

  1. Docking a widget to fill a dialog
    By mridey in forum Qt Tools
    Replies: 1
    Last Post: 16th November 2006, 11:45

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.