Results 1 to 9 of 9

Thread: How can I implement a resizable textbox in Qt

  1. #1
    Join Date
    Jul 2012
    Posts
    201
    Thanks
    26
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default How can I implement a resizable textbox in Qt

    hi there guys. I want to implement something like this in Qt Image 15.jpg. The functionality must be the same as that of the windows paint program. This will obviously be added into a QGraphicsScene with other item. How do i implement something like this in Qt? thanking you in advance.

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: How can I implement a resizable textbox in Qt

    Does "like this" mean anything specific?
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  3. #3
    Join Date
    Jul 2012
    Posts
    201
    Thanks
    26
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: How can I implement a resizable textbox in Qt

    Quote Originally Posted by wysota View Post
    Does "like this" mean anything specific?
    There is a screenshot attachment after the words "like this one". If you open the attachment you will see the screenshot and see what I am talking about. Here is the screenshot again.Image 15.jpg

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: How can I implement a resizable textbox in Qt

    I don't think you are asking how to put that screenshot in your application. So again, what exactly do you mean? If you are after putting a white rectangle in graphics view then QGraphicsScene::addRect() will add a rectangle.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  5. #5
    Join Date
    Jul 2012
    Posts
    201
    Thanks
    26
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: How can I implement a resizable textbox in Qt

    Quote Originally Posted by wysota View Post
    I don't think you are asking how to put that screenshot in your application. So again, what exactly do you mean? If you are after putting a white rectangle in graphics view then QGraphicsScene::addRect() will add a rectangle.
    Okay i am going to try and be as clear as possible. My program must add a QGraphicsTextitem into a QGraphicsScene but I want the QGraphicsTextItem to be added in form of a resizable box like in the attachment above (Please DO NOT look at the white rectangle in the attachment, I am interested in the textItem on the rectangle.) Here is an example below.

    Please see this attachmentImage 16.png. This is how my textItem gets added into the scene which means I cannot resize the item by dragging the anchors.
    This is what I want to achive Image 17.png. I hope this is clear.

  6. #6
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: How can I implement a resizable textbox in Qt

    Quote Originally Posted by ayanda83 View Post
    Okay i am going to try and be as clear as possible.
    Great.

    Please see this attachment. This is how my textItem gets added into the scene which means I cannot resize the item by dragging the anchors.
    What have you tried so far to make it resizable? Have you reimplement any events?
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  7. #7
    Join Date
    Jul 2012
    Posts
    201
    Thanks
    26
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: How can I implement a resizable textbox in Qt

    Quote Originally Posted by wysota View Post


    What have you tried so far to make it resizable? Have you reimplement any events?
    Not really; and that is because I have no clue where to begin trying to reproduce something like this. I would greatly appreciate a push in the right direction and by that I mean what classes am I suppose to be looking at, the rest I will figure out myself with the help of the Qt documentation. thank you.

  8. #8
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: How can I implement a resizable textbox in Qt

    Quote Originally Posted by ayanda83 View Post
    Not really; and that is because I have no clue where to begin trying to reproduce something like this. I would greatly appreciate a push in the right direction and by that I mean what classes am I suppose to be looking at, the rest I will figure out myself with the help of the Qt documentation. thank you.
    The problem is that for every feature you want to implement you are not trying to do research yourself but instead you immediately come here and ask how you should do it. How do you expect to learn this way? Looking at classes is one of the last things you should be doing. First you should have at least a general concept how to solve the problem. Then you can ask which classes would best fit your algorithm and whether it is a good approach at all.

    The classes you should be looking at are QGraphicsView, QGraphicsScene and QGraphicsItem. I don't think having that list is helpful at all.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  9. #9
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,230
    Thanks
    302
    Thanked 864 Times in 851 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: How can I implement a resizable textbox in Qt

    And I think if you studied the "Diagram Scene", "Elastic Nodes", and other Graphics / View examples from your Qt distribution, you would find much of what you need there...

Similar Threads

  1. Replies: 2
    Last Post: 4th January 2014, 12:01
  2. Replies: 3
    Last Post: 15th April 2013, 18:42
  3. textbox+highlighter
    By nima in forum Qt Programming
    Replies: 0
    Last Post: 27th June 2011, 15:39
  4. Replies: 1
    Last Post: 28th December 2010, 09:43
  5. Textbox
    By Devoraz in forum Qt Programming
    Replies: 6
    Last Post: 23rd July 2009, 06:37

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.