Setting window size including window frame



  • Hey.

    I am developping an application that needs to be 1024x768. I set the size in QTDesigner using the minimuSize and maximumSize parameters of the widget. Problem is that these dimensions do not include the Windows frame. I end up with a window that is larger than 1024x768.

    Is there a way to set the window size while including the Windows frame.

    • I need to keep the Windows frame
    • I had a look at the Window Geometry page of the Qt doc. Apparently, the x() and y() parameters are what I am looking for but I just cannot figure out a way to use them.

    Thanks a lot



  • I think it is not possible because window frame painting depends on Windows Manager system.

    Also if you set 1024x768 (with frame) and run app on 800x600 it's again will bad.

    Why do you not want using window maximizing?

    @void QWidget::showMaximized()@



  • This size is the minimum size required in the specifications. The soft is not designed to work on a 800x600 screen.



  • you can only do it "by hand" in the constructor of the class.
    The window frame depends on system settings, which change from OS to OS and from OS version to OS version and also depend on user settings.

    On Windows, you can read them by calling "GetSystemMetics":http://msdn.microsoft.com/en-us/library/ms724385(v=vs.85).aspx



  • I found stg like that on the web. Is it valid ?

    @widthofframe = frameGeometry().width() - geometry().width();
    //divide this by 2 for one side's width

    heightofframeandtitlebar = frameGeometry().height() -
    geometry().height()
    heightoftitlebar = heightofframeandtitlebar - (frameGeometry().width() -
    geometry().width());@



  • Hi,

    just a suggestion: why don't elide totally the standard window frame, creating a frameless window with the controls you need on a button toolbar that can be set to disappear when not needed ?



  • [quote author="Alicemirror" date="1316012242"]Hi,

    just a suggestion: why don't elide totally the standard window frame, creating a frameless window with the controls you need on a button toolbar that can be set to disappear when not needed ?[/quote]

    This only works, if you are not on windows or don't need taskbar support and default menus. a maximized, frameless app on windows is fulllscreen, no taskbar visible etc... ;-(

    [quote author="Thibaut" date="1316011992"]I found stg like that on the web. Is it valid ?

    @widthofframe = frameGeometry().width() - geometry().width();
    //divide this by 2 for one side's width

    heightofframeandtitlebar = frameGeometry().height() -
    geometry().height()
    heightoftitlebar = heightofframeandtitlebar - (frameGeometry().width() -
    geometry().width());
    @
    [/quote]

    This works, if the app is already visoble, but typically, you want to set such things in the constructor, there it will not work.



  • @Gerolf: sure, I know it because I had to use this approach. But is you see the most recent Qt versions (for sure 4.7.3 and further) support the Qt quick components in the desktop environment too. I suggested to manage a really full screen window (that save space for the app if I have understood that it is needed as much more scren as possible) and manage the options using a common toolbar, at the bottom.

    Instead of this method there is also what I have set to save space on some applicaitons for small screens, where a custom toolbar appears when the mouse is near the top of the screen.

    Don't you think it is possibe ?



  • It could be possible, but if it changes app behavior for some OSs, it should be stated. I know many people, who are scared on desktops, if they try to maximize apps and they got fullscreen.
    Afterwards they want to access e.g. outlook, browser or whatever and the taskbar is not visible...



  • Yes, I see.

    e.g. the F11 Key with Firefox. What is your advice ?



  • use the OS api and calculate by hand :-)



  • If I remember there are information that can be get from the Api about window decoration sizes, borders etc.



  • [quote author="Alicemirror" date="1316016905"]If I remember there are information that can be get from the Api about window decoration sizes, borders etc.[/quote]

    Really? AFAIK, if the widgets are displayed, you can use geometry and frameGeometry, but to get the OS defaults?



  • I don't remember this detail, but I had a big problem managing a windowless application for Windows 7 and investigating on the functions to obtain the result that I was expecting I remeber that I have found some information about the window geometry. As I have a minute I will check what it was. I save always the useful documents for a project in a pdf folder :)



  • in mainwidow.ui > MainWindow > Property > Qwidget >geometry


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.