Results 1 to 7 of 7

Thread: Adding a QSizeGrip to a QMainWindow

  1. #1
    Join Date
    Oct 2006
    Posts
    83
    Thanks
    1
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Adding a QSizeGrip to a QMainWindow

    I have removed the status bar from my mainwindow by doing the following:
    Qt Code:
    1. setStatusBar(0);
    To copy to clipboard, switch view to plain text mode 

    I now want to add a QSizeGrip back to the mainwindow so that the user can resize it. I want to show it in the bottom right corner. I tried the following below, yet it shows the size grip, but it shows up somewhere near the top left corner:
    Qt Code:
    1. // This is within the mainwindow
    2. grip = new QSizeGrip(this);
    3. grip->resize(grip->sizeHint());
    To copy to clipboard, switch view to plain text mode 

    Any ideas on how to get this to work?

    Thanks!
    Last edited by forrestfsu; 14th March 2007 at 19:25.

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

    Default Re: Adding a QSizeGrip to a QMainWindow

    I think you'll have to reimplement resizeEvent() and position the size grip manually on every resize.

  3. #3
    Join Date
    Oct 2006
    Posts
    83
    Thanks
    1
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Adding a QSizeGrip to a QMainWindow

    Thanks for the pointer Wysota. I was able to get the QSizeGrip to show in the bottom right corner now.

    However, I have run into two issues.

    First, it seems by default the QSizeGrip is setup to act as if it were in the top-left corner, rather then the bottom-right corner. The default cursor is "Qt::SizeFDiagCursor", but I need it to be "Qt::SizeBDiagCursor"...but for some reason when I set the cursor to "Qt::SizeBDiagCursor" it remains as "Qt::SizeFDiagCursor". Other cursors do work though (i.e. - Qt::CrossCursor)...is there any specific reason why?

    The second issue is that when I drag the sizegrip it acts as if it were in the top-left corner. For example, by dragging it upward, it expands the top of the window vertically, when it should be contracting the window vertically. Any idea how to fix this?

    Thanks for any advice.

    - jesse

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

    Default Re: Adding a QSizeGrip to a QMainWindow

    I'd take a look into QMainWindow source code to see how it handles it. But at worst you can reimplement event handlers and "reverse" them before calling the base implementation.

  5. #5
    Join Date
    Oct 2006
    Posts
    83
    Thanks
    1
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Adding a QSizeGrip to a QMainWindow

    Might sound stupid, but where is the source available?

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

    Default Re: Adding a QSizeGrip to a QMainWindow

    www.trolltech.com

    Or go to our front page and look at the lower right corner of the screen.

  7. #7
    Join Date
    Oct 2006
    Posts
    83
    Thanks
    1
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Adding a QSizeGrip to a QMainWindow

    I've looked through QMainWindow, QSizeGrip, and QStatusBar source code. Unfortunately I'm not seeing where exactly they set the cursor and and resize events. I noticed a function within QSizeGrip.cpp called "qt_sizegrip_atBottom()"...but I'm unsure if that is relevant. Any pointers to head me in the right direction?

Similar Threads

  1. Disabling the Maximize button in QMainWindow ?
    By sunil.thaha in forum Qt Programming
    Replies: 17
    Last Post: 26th June 2017, 13:31
  2. How do I add a QGridlayout in a QMainwindow?
    By Teuniz in forum Qt Programming
    Replies: 4
    Last Post: 14th February 2007, 10:18
  3. Adding buttons on the tab part of a tabwidget
    By forrestfsu in forum Qt Programming
    Replies: 2
    Last Post: 20th December 2006, 17:52
  4. Dynamically Loading a QMainWindow?
    By natron in forum Newbie
    Replies: 10
    Last Post: 21st July 2006, 01:15
  5. Replies: 18
    Last Post: 22nd February 2006, 20:51

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.