Results 1 to 9 of 9

Thread: Qt setMask and resizing

  1. #1
    Join Date
    Jan 2007
    Location
    Paris
    Posts
    459
    Thanks
    98
    Thanked 3 Times in 3 Posts
    Qt products
    Qt4 Qt5

    Default Qt setMask and resizing

    Hey there,

    I'm specifiying a mask using setMask on my main Widget.
    Graphicaly It's working fine.

    The only problem is the fact that I loose the window control for resizing.

    Is it possible to enable it back?

    Thanks.

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,018 Times in 4,794 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Qt setMask and resizing

    Could you explain? What do you mean you lose control for resizing? You mask out the corner?

  3. #3
    Join Date
    Jan 2007
    Location
    Paris
    Posts
    459
    Thanks
    98
    Thanked 3 Times in 3 Posts
    Qt products
    Qt4 Qt5

    Default Re: Qt setMask and resizing

    Yes,

    I've masked the borders and the corners.

    I guess the behaviour I'd like to optain is : even if the borders and corners are hidden, still process the user's event like stretching and resizing.

  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: Qt setMask and resizing

    Quote Originally Posted by bunjee View Post
    I've masked the borders and the corners.
    Resizing by dragging from window decoration is provided by the underlying window system, not by Qt. So unfortunately, if you mask the decoration out, you're on your own. You can try to make use of QSizeGrip.
    J-P Nurmi

  5. #5
    Join Date
    Jan 2007
    Location
    Paris
    Posts
    459
    Thanks
    98
    Thanked 3 Times in 3 Posts
    Qt products
    Qt4 Qt5

    Default Re: Qt setMask and resizing

    Are you sure there is no simpler way ?

    Anybody reimplemented the resize window algorithm on a QWidget ?

  6. #6
    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

    Quote Originally Posted by bunjee View Post
    Are you sure there is no simpler way ?
    What's more simple than placing a QSizeGrip into each corner (possibly with help of QGridLayout) and voilá? Optionally you can subclass QSizeGrip and reimplement its paintEvent() handler to draw nothing. I mean, QSizeGrip provides resizing functionality into each direction out of the box.
    J-P Nurmi

  7. #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

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

    bunjee (21st November 2007)

  9. #8
    Join Date
    Jan 2007
    Location
    Paris
    Posts
    459
    Thanks
    98
    Thanked 3 Times in 3 Posts
    Qt products
    Qt4 Qt5

    Default Re: Qt setMask and resizing

    That's exactly what I just coded .

    But,
    It's only working for the corners of the widget, not for the sides.

    So there is more work to do to completely emulate the window's behaviour.

  10. #9
    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

    Quote Originally Posted by bunjee View Post
    But,
    It's only working for the corners of the widget, not for the sides.

    So there is more work to do to completely emulate the window's behaviour.
    That's right. You might want to take a peek into QSizeGrip sources for implementation tips.
    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.