Results 1 to 6 of 6

Thread: Placing a widget at fixed place on top of QAbstractScrollArea (actually QGV)

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jan 2007
    Posts
    45
    Thanks
    5
    Thanked 1 Time in 1 Post
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default Re: Placing a widget at fixed place on top of QAbstractScrollArea (actually QGV)

    No, the widget is allocated on the heap.

  2. #2
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: Placing a widget at fixed place on top of QAbstractScrollArea (actually QGV)

    At least this works for me:
    Qt Code:
    1. #include <QtGui>
    2.  
    3. int main(int argc, char *argv[])
    4. {
    5. QApplication a(argc, argv);
    6.  
    7. QGraphicsItem* item = scene.addRect(QRectF(0,0,25,25));
    8. item->setFlag(QGraphicsItem::ItemIsMovable);
    9.  
    10. view.setScene(&scene);
    11. QLabel* label = new QLabel("Test", &view);
    12. Q_UNUSED(label);
    13.  
    14. view.show();
    15. return a.exec();
    16. }
    To copy to clipboard, switch view to plain text mode 
    J-P Nurmi

  3. #3
    Join Date
    Jan 2007
    Posts
    45
    Thanks
    5
    Thanked 1 Time in 1 Post
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default Re: Placing a widget at fixed place on top of QAbstractScrollArea (actually QGV)

    Yes, your code works for me too. It seems that I've found a reason for my problem: I've created a widget from QGraphicsView-derived class constructor and viewport was created after it and after raise() call - so my widget was simply covered by viewport. Sorry for disturbing you.

  4. #4
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: Placing a widget at fixed place on top of QAbstractScrollArea (actually QGV)

    Ok, great that the problem was solved. And no worries, this was not disturbing at all!
    J-P Nurmi

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.