PDA

View Full Version : AddLine over QGraphicsscene Pixmap



Qt Coder
25th March 2009, 07:18
Hi all,

I m using Qt 4.4.3

I have taken one QVBoxLayout ,in which I m displaying one image using QGraphicsView

Now I want to draw/add line over the image which I set for graphics scene.how to do that


Below is the code for above thing

QVBoxLayout *ArrowLayout;
QGraphicsView *LeftArrowGraphicsView = new QGraphicsView;
QGraphicsScene *scene_LeftArrow = new QGraphicsScene;

pPixMapItemLeftArrow = scene_LeftArrow->addPixmap(QPixmap(QString::fromUtf8("Images/Arrow1.PNG")));
LeftArrowGraphicsView->setScene(scene_LeftArrow);
LeftArrowGraphicsView->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOf f);
LeftArrowGraphicsView->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff) ;
ArrowLayout->addWidget(LeftArrowGraphicsView);

Qt Coder
25th March 2009, 07:33
:D

Hey I got solution for it



QPen pen(Qt::blue, 1);
QLineF line(10, 20, 300,300);
scene_LeftArrow->addLine(line,pen);


thats it!!!!

Qt Coder
25th March 2009, 08:08
Can anyone tell me how to set thickness of line?????????

Lykurg
25th March 2009, 08:12
QPen pen(Qt::blue, 9878346374);
:D

EDIT: It is allways good if one understand his own code...