Why a GUI looks different on different Windows versions?



  • Hy everyone,
    I did a GUI under windows 7, everything works and looks fine, but when I run it under windows 10 it looks ugly, I mean, the background is not grey , it is white, and I can barely see the buttons and spinboxes since there is almost no contrast. Why does it happens? What can I do to avoid it? I wonder what i would look like if I run it on Linux...


  • Moderators

    Which Qt version are you using? Perhaps it is some oldie from before Windows 10 release?



  • @Flavio-Mesquita
    Hi, friend. welcome.

    Different system has the different windows, dialog, and button ... styles.

    Qt default used the system style.

    When you using Qt Widget in Win7, Qt default use Win7 Dialog style.
    When you using Qt Widget in Win10, Qt default use Win10 Dialog style.
    and also has Mac system,Ubuntu system, They are both different.

    If you want to uniform style of widgets in different system.

    The only way is to repaint widget, like subclass QWidget,, or use QSS.

    more information, please to see Qt help manual.

    like QPushButton QTabWidget QLabel ... Widget class.



  • @sierdzio Hi, I used Qt creator 4.6.1, with Qt5.10. I downloaded it about a month ago.


  • Moderators

    @Flavio-Mesquita said in Why a GUI looks different on different Windows versions?:

    @sierdzio Hi, I used Qt creator 4.6.1, with Qt5.10. I downloaded it about a month ago.

    OK that is recent enough.

    When you say you run it under Windows 10, does it mean you compile it on Win10, or compile on Win7 and copy the .exe file to Win10, then open?

    If the latter, then check out https://doc.qt.io/qt-5/windows-deployment.html



  • @sierdzio I had already looked at he document you referenced and compiled it on windows 7. Used the windeployqt, that copied all the dependency files to the folder. Then I copied the whole folder with the .exe file together and put it in a computer with windows 10. When clicking on .exe file it executes, but looks weird.

    I did like said in the document:

    "The tool can be found in QTDIR/bin/windeployqt. It takes an .exe file or a directory that contains an .exe file as an argument, and scans the executable for dependencies. If a directory is passed with the --qmldir argument, windeployqt uses the qmlimportscanner tool to scan QML files inside the directory for QML import dependencies. Identified dependencies are then copied to the executable's directory. The hardcoded local paths in Qt5Core.dll are furthermore replaced with relative ones.

    For Windows desktop applications, the required runtime files for the compiler are also copied to the deployable folder by default (unless the option --no-compiler-runtime is specified). In the case of release builds using Microsoft Visual C++, these consist of the Visual C++ Redistributable Packages, which are intended for recursive installation by the application's installer on the target machine. Otherwise, the shared libraries of the compiler runtime are used."



  • @joeQ what do u mean by QSS?


  • Qt Champions 2017



  • Hy guys I ended up using as the example at the documentation:
    QApplication::setStyle(QStyleFactory::create("Fusion"));
    just added this line on the main.cpp, it worked fine.

    Just one more question, I want to add a logo on the widget, it works fine on my computer, but if I want it to load on another computer do i have to create a folder with the same address as it was on my computer and put the image.png there?


  • Qt Champions 2017

    @Flavio-Mesquita said in Why a GUI looks different on different Windows versions?:

    Just one more question, I want to add a logo on the widget, it works fine on my computer, but if I want it to load on another computer do i have to create a folder with the same address as it was on my computer and put the image.png there?

    Hi, it would be far better to put logo in resource file so its included in the exe.

    http://doc.qt.io/qt-5/resources.html

    http://www.bogotobogo.com/Qt/Qt5_Resource_Files.php



  • @mrjj Thanks for the answer, that is what I like about this community, u guys are always willing to help noobs like me. I did what u pointed , it works fine, still gives a warning like below, but it works. Thank u very much.

    C:\Users\Flavio\Documents\qtTest\interface2_v2\main.cpp:9: warning: label 'read' defined but not used [-Wunused-label]
    read:(":/logo/uff.png");
    ^


  • Qt Champions 2017

    Well we love beginners here :)
    I think it says you have a variable you dont use.
    Anywhow, just to be clear
    iF you have a QLabel to show logo in. ( not sure what widget you have)
    Then you can do
    Label->setPixmap( QPixmap(":/logo/uff.png"));

    Not sure what read: is :)



  • @mrjj on the example about the resources, besides adding the resource file to the project we had to add a line with the read command pointing to the logo path at the main.cpp file. maybe it was not necessary since I had the code implementing it under the interface.cpp as u mentioned.
    Thanks anyway, soon I will come up with lots of more projects since I´m pushing to my teachers at the college to use Qt as our main tool for GUI development classes in the next semester.


  • Qt Champions 2017

    @Flavio-Mesquita
    Sounds not needed but not 100% sure what you do with it.
    I guess my point was if you can use QPixmap/QImage directly, you dont need QFile or anything like that.

    Oh, that sounds like a great plan. I hope he will.


Log in to reply
 

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