Results 1 to 4 of 4

Thread: strange problem in QGraphicsView

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    May 2007
    Posts
    91
    Thanks
    60
    Qt products
    Qt4
    Platforms
    Windows

    Default strange problem in QGraphicsView

    Qt Code:
    1. test::test(QWidget *parent, Qt::WFlags flags)
    2. : QMainWindow(parent, flags)
    3. {
    4. ui.setupUi(this);
    5.  
    6. QString str = "test";
    7. pixTrans.load("Resources/Trans.bmp");
    8.  
    9. view.setScene(&scene);
    10. setCentralWidget(&view);
    11.  
    12. showText(&str,0,0);
    13. showItem(&pixTrans,0,0);
    14. showText(&str,0,100);
    15. showItem(&pixTrans,0,100);
    16. }
    17.  
    18. void test::showItem(QPixmap *pixmap, int x, int y)
    19. {
    20. QGraphicsPixmapItem* i = scene.addPixmap(*pixmap);
    21. i->setPos(x,y);
    22. }
    23. void test::showText(QString *str, int x, int y)
    24. {
    25. QGraphicsTextItem* i = scene.addText(*str);
    26. i->setPos(x, y);
    27. }
    To copy to clipboard, switch view to plain text mode 
    the result is so strange:
    the 1st text "test" at (0,0) is covered by the pixmap "pixTrans"
    while the 2nd text "test" at (0,0) is on top of the pixmap "pixTrans"
    I want to show text on top of pixmap at the same coordinate (x,y), is there any way to do this ?
    thanks very much for suggestion!
    Attached Images Attached Images
    Last edited by Shawn; 29th June 2007 at 08:55.

Similar Threads

  1. QGraphicsView scrolling problem with 4.3.0
    By hb in forum Qt Programming
    Replies: 8
    Last Post: 30th August 2007, 22:18
  2. Strange shortcut problem
    By blukske in forum Qt Programming
    Replies: 0
    Last Post: 13th March 2007, 10:26
  3. Strange problem with events on Unix
    By sukanyarn in forum Qt Programming
    Replies: 2
    Last Post: 7th November 2006, 02:45
  4. Strange Problem with JPEG Support on win XP
    By caligula in forum Installation and Deployment
    Replies: 3
    Last Post: 18th September 2006, 10:36
  5. Replies: 16
    Last Post: 7th March 2006, 15:57

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
  •  
Qt is a trademark of The Qt Company.