PDA

View Full Version : How can I implement a resizable textbox in Qt



ayanda83
28th April 2015, 14:18
hi there guys. I want to implement something like this in Qt 11143. 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.

wysota
28th April 2015, 15:13
Does "like this" mean anything specific?

ayanda83
28th April 2015, 16:47
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.11145

wysota
28th April 2015, 17:07
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.

ayanda83
28th April 2015, 17:58
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 attachment11146. 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 11147. I hope this is clear.

wysota
28th April 2015, 18:28
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?

ayanda83
28th April 2015, 18:37
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.

wysota
28th April 2015, 21:38
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.

d_stranz
29th April 2015, 18:07
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...