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

    w.showMaximized();
    w.showNormal();
    w.showMaximized();
    

    to have the window really maximized.

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

    thanks

    br
    R



  • Hi, welcome to Devnet.

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

    w.setWindowState(Qt::WindowMaximized);
    


  • 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);
    
        a.setApplicationName(_APPNAME_);
        a.setApplicationVersion(_APPVERSION_);
        a.setOrganizationName(_ORGNAME_);
        a.setOrganizationDomain(_ORGDOMAIN_);
        QString appname;
        appname = _DISPNAME_;
        appname.append(" v");
        appname.append(_APPVERSION_);
    
        a.setApplicationDisplayName(_DISPNAME_ " v" _APPVERSION_ _SUBVERSION_);
    
    a.setStyle(QStyleFactory::create("Fusion"));
    
    QString css;
     QFile cssfile("main.css");
    if(cssfile.open(QFile::ReadOnly)) {
            css.append(cssfile.readAll());
        }
    MainWindow w;
    w.setStyleSheet(css);
    w.showMaximized();
    //    w.showNormal();
    //    w.showMaximized();
    
        return a.exec();
    

    //Edit
    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.


  • Moderators

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



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


Log in to reply
 

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