Results 1 to 2 of 2

Thread: QT5 / items / setPos / graphicsView

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Feb 2017
    Posts
    2
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default QT5 / items / setPos / graphicsView

    This is my code

    I'd like to setPos() but with the ui->graphicsView->setAlignment(Qt::AlignTop|Qt::AlignLeft); all the items are at left I can only change setPos(x,y); y value

    How can I do to use setPos() ?
    Qt Code:
    1. QString txt=ui->lineEdit->text();
    2.  
    3.  
    4. text->setHtml("100");
    5.  
    6.  
    7. text2->setHtml("100");
    8.  
    9.  
    10. line->setLine(0, 0, 50, 0);
    11.  
    12.  
    13. text3->setHtml("200");
    14.  
    15. sc->addItem(text);
    16. sc->addItem(text2);
    17. sc->addItem(text3);
    18.  
    19. sc->addItem(line);
    20.  
    21. text->setPos(30, 0);
    22. text2->setPos(30, 20);
    23. text3->setPos(30, 45);
    24. line->setPos(30, 40);
    25.  
    26. ui->graphicsView->setScene(sc);
    27.  
    28. ui->graphicsView->setAlignment(Qt::AlignTop|Qt::AlignLeft);
    29.  
    30. ui->graphicsView->update();
    To copy to clipboard, switch view to plain text mode 
    Last edited by anda_skoa; 3rd March 2017 at 07:54. Reason: missing [code] tags

Similar Threads

  1. Replies: 3
    Last Post: 11th December 2011, 10:09
  2. Qt 4.6 GraphicsView items remove problem
    By Piskvorkar in forum Qt Programming
    Replies: 10
    Last Post: 10th March 2010, 09:08
  3. QGraphicsItem setpos()
    By qtuser20 in forum Qt Programming
    Replies: 6
    Last Post: 3rd August 2009, 17:17
  4. Light items for the graphicsView
    By maverick_pol in forum Qt Programming
    Replies: 12
    Last Post: 1st November 2007, 18:51
  5. Zoom GraphicsView but not Items
    By abbapatris in forum Qt Programming
    Replies: 2
    Last Post: 15th October 2007, 19:47

Tags for this Thread

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.