PDA

View Full Version : Newbie needs advice - QGraphicsLineItem



Seth
28th May 2007, 23:12
Hi All,

(QT 4.2.3 using MinGW) Dont know much about programming (serious rookie) so starting from scratch and need advice.

I have a main window up and running and want to add a Line using QGraphicsLineItem but dont know how to build that class.

Where can I find information on how to add things like a Line using QGraphicsLineItem to a main Window?

Thanks in advance
:)

marcel
29th May 2007, 04:47
No need to build a class for that, at least not just yet.
You need to:
- add a QGraphicsView to your window( from Designer, or whatever );
- add a QGraphicsScene to this view;
- add a line item by:
- create a QGraphicsLineItem and add it to the scene with QGraphicsScene::addItem
- use the convenience functions from the QGraphiscScene::addLine familiy.

But before you draw something read http://doc.trolltech.com/4.3/graphicsview.html.

Regards

wysota
29th May 2007, 08:41
You want to have a line on your form or you want to use the graphics view? Because you can have lines without the graphicsview, so if you explained what you intend to do with this line, we might suggest an alternative solution.

Seth
30th May 2007, 00:43
Wysota, I want a line, I will manipulate that line eventually, making longer or shorter, adding characteristics to it like if its 1000 meters long it has 10 ohms of resistance per meter.

So like I said I am so fresh never wrote a program before, so I need to start small, want to get a line up and running that I can make longer or shorter by means of another widget and then I will add characteristics like resistance and such.

I have read
But before you draw something read http://doc.trolltech.com/4.3/graphicsview.html. but I am having a hard time interpreting those fundamentals.

Where is a good place to start learning the basics graphics view?

wysota
30th May 2007, 08:23
Wysota, I want a line, I will manipulate that line eventually, making longer or shorter, adding characteristics to it like if its 1000 meters long it has 10 ohms of resistance per meter.
But is the line a goal of its own? What would you like to have in the end? Are you implementing some schematic drawing application or something?


Where is a good place to start learning the basics graphics view?

Start by taking a look at examples concerning the graphics view if that's really what you need (I'm not sure about that though).