Important: Please read the Qt Code of Conduct -

Maximized MainWindow on Win10 TabletMode

  • Hi all,

    I have a strange behaviour with an application i wrote some time ago. When I try to start it on Win10 in the "Tablet Mode" the window does not go to maximized, even the icon in the window title shows maximized. THe strange thing is, that this happens not all time i try to start this program (3 out of 10 starting correct).
    It works in "Desktop Mode" on WIn10 , also on Win7 and Win 8/8.1 although i have to show the mainwindow with


    to have the window really maximized.

    Has anyone a solution to have a correctly maximized window in TabletMode?



  • Hi, welcome to Devnet.

    Not sure this is going to work any better, but you can try setWindowState instead:


  • Hi,

    Thanks for that hint

    It works as expected when I compile it for Debug but not for Release on Win8.1.
    As Release Build it still shows the MainWindow in original size with the Maximized icon in the window title.
    I can't try on Win10 for now because i do not have any device available at the moment.

  • I'll need your code to understand what is going on.
    What is the type of your w variable? Do you set some flags manually? sometimes it causes glitches when you try to interfere in widget mechanisms.

  • Hmm,

    seems to be not the problem of Debug or Release Build.
    In the main.cpp I load a css file to set some styles for the App. This file only exists in Release Build and seems to mess up something.

    Here is the code

    //your code here
    QApplication a(argc, argv);
        QString appname;
        appname = _DISPNAME_;
        appname.append(" v");
        a.setApplicationDisplayName(_DISPNAME_ " v" _APPVERSION_ _SUBVERSION_);
    QString css;
     QFile cssfile("main.css");
    if( {
    MainWindow w;
    //    w.showNormal();
    //    w.showMaximized();
        return a.exec();

    I tried the same code on a unix machine, there it works even with the css String set to some stylesheet things
    It does not matter where I write w.setWindowState() as long as css != "" it does not work as expected

    //Edit 2nd
    I ran over the stylesheet again and found out that it seems to be a problem on windows to set

    QWidget { font-size: xxpt;}

  • I think i have solved the problem

    if I try to set the global font size in the main.cpp wit a.setFont() it messes up everything.

    Setting the font in the mainwindow with QApplication::setFont() does well.

  • @the_ Hi! Very strange. Please be so kind and file a bug report. Thank you :-)

  • @Wieland
    Bugreport is sent and got low priority ;)