PDA

View Full Version : Default size of window on different platforms



guitargentlyweeps
12th March 2012, 19:13
Hi,

I've searched the forum and tried different things to solve this to no avail.

I have an application that shows a QDialog derived dialog from a QMainWindow derived class. I'm building on a mac with a high res display and the dialog shows fine. When I build on a linux box with a lower resolution display, the top and bottom of the dialog extends above and below the screen respectively. If I use setFixedSize() on my dialog I can display the whole thing on this lower res display fine but then I can't re-size if I want to. Also, this is a ham handed way of sizing a window. Obviously using setMaximumHeight() or setMaximumWidth() won't work because they just restrict re-sizing. How can I use the dimensions of my display, which I can retrieve with a call to availableGeometry(), to size my dialog properly? What function can I plug these values into to achieve this? What am I missing here, this should be simple.

Thanks for the consideration in advance. Much appreciated.

wysota
12th March 2012, 19:26
Does it help if right after calling show() on your widget you call this line?


widget->resize(widget->sizeHint());

guitargentlyweeps
13th March 2012, 14:55
Thanks for your response. Unfortunately, this seems to have no effect.

One clue is that if instead of using widget->show(), I use widget->showMaximized(), the whole dialog will show and fill up the entire screen. The layouts in the dialog appear to be a little crowded, so maybe due to the size of the layouts in my dialog and the resolution of my display, it's not possible to fit properly? Hence, I can not get resize() to work right?

Added after 20 minutes:

Sorry all. It looks like my problem all along was that my dialog with all of its layouts was just too big for the resolution of the monitor that I was attempting to display it on. I suppose that sizeHint() can only help so much. What I did was reorganized my layouts so that my dialog extended in a more horizontal fashion which helped.

Thanks to all who looked at this post. Much appreciated.