PDA

View Full Version : Adding a QSizeGrip to a QMainWindow



forrestfsu
14th March 2007, 19:15
I have removed the status bar from my mainwindow by doing the following:


setStatusBar(0);


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:


// This is within the mainwindow
grip = new QSizeGrip(this);
grip->resize(grip->sizeHint());


Any ideas on how to get this to work?

Thanks!

wysota
15th March 2007, 06:14
I think you'll have to reimplement resizeEvent() and position the size grip manually on every resize.

forrestfsu
19th March 2007, 17:19
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

wysota
19th March 2007, 18:14
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.

forrestfsu
19th March 2007, 21:44
Might sound stupid, but where is the source available?

wysota
19th March 2007, 22:15
www.trolltech.com :)

Or go to our front page (http://www.qtcentre.org) and look at the lower right corner of the screen.

forrestfsu
9th April 2007, 15:45
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?