Results 1 to 9 of 9

Thread: Qt setMask and resizing

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #7
    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: Qt setMask and resizing

    Give it a try:
    Qt Code:
    1. // main.cpp
    2. #include <QtGui>
    3.  
    4. class MaskWindow : public QWidget
    5. {
    6. public:
    7. MaskWindow()
    8. {
    9. QGridLayout* grid = new QGridLayout(this);
    10. grid->addWidget(new QSizeGrip(this), 0, 0, Qt::AlignTop | Qt::AlignLeft);
    11. grid->addWidget(new QSizeGrip(this), 0, 2, Qt::AlignTop | Qt::AlignRight);
    12. grid->addWidget(new QSizeGrip(this), 2, 0, Qt::AlignBottom | Qt::AlignLeft);
    13. grid->addWidget(new QSizeGrip(this), 2, 2, Qt::AlignBottom | Qt::AlignRight);
    14. grid->addWidget(new QLabel("Content", this), 1, 1, Qt::AlignCenter);
    15. grid->setSpacing(0);
    16. grid->setMargin(0);
    17. }
    18.  
    19. protected:
    20. void resizeEvent(QResizeEvent* event)
    21. {
    22. QWidget::resizeEvent(event);
    23. setMask(rect());
    24. }
    25. };
    26.  
    27. int main(int argc, char *argv[])
    28. {
    29. QApplication a(argc, argv);
    30. MaskWindow w;
    31. w.show();
    32. return a.exec();
    33. }
    To copy to clipboard, switch view to plain text mode 
    J-P Nurmi

  2. The following user says thank you to jpn for this useful post:

    bunjee (21st November 2007)

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.