Dear visitor, welcome to QtForum.org.
If this is your first visit here, please read the Help. It explains in detail how this page works.
To use all features of this page, you should consider registering.
Please use the registration form, to register here or read more information about the registration process.
If you are already registered, please login here.
How to draw many items in scene
Hi,
I draw line on defined scene but when I want to draw item should I write this line
for example to draw two line should I write that :
|
Source code
|
1
2
3
4
5
|
QGraphicsLineItem *line1 = new QGraphicsLineItem(0,&scene)
p, li { white-space: pre-wrap; line1->setLine(0.0,0.0,10.0,10.0);
QGraphicsLineItem *line2 = new QGraphicsLineItem(0,&scene);
line2->setLine(0.0,0.0,10.0,10.0);
How can avoid this? I need to draw may lines without repeate that line
|
Could you use a loop?
For example:
for (int i = 0; i < theNumberOfLinesYouWant; i++)
{
QGraphicsLineItem *line = new QGraphicsLineItem(0, &scene);
line->setLine(0.0, 0.0, 10.0, 10.0);
}
I know loop but I mean is there any another way for line definition of line for example in QPainter
QPainter line;
line.drawline(.......); // first line
line.drawLine (......); // second line
.
.
.
that is good , but i will find problem when I want to change the item coordinate because the line will be drawn on the scene coordinate
i need in the QGraphicsItem terms
I got it , Thanks for every one here