Qt5 to Qt6 style changes
-
We are in the process of moving from qt5.15 to Qt6. In the process, we've noticed that the style has changed on linux, not so much on windows. This is documented in Qt documentation.
We are tying to get the style on linux to look more like it did in Qt5 which is also the way it still looks on windows.
What I have found is that I should be able to do this using QApplication::setStyle like this:
QApplication::setStyle("fusion");I've tried "fusion" and "windows" and various other methods and styles. None of them seem to make a difference. What is the proper way of setting the linux style to match either what was in Qt5 or what it is on windows in Qt6?
-
Hi,
Which version of Qt are you using ? The one from your installer or the one from your distribution ?
Note that OS specific styles are not available on all platforms because they contain OS specific code. -
Hi,
Which version of Qt are you using ? The one from your installer or the one from your distribution ?
Note that OS specific styles are not available on all platforms because they contain OS specific code.@SGaist 6.7-3. From an installer from Qt. We did not build it ourselves.
Online it says that fusion should work to make things look like they did in Qt5.
We are noticing background color changes, especially in various widgets, probably QLineEdit. The widget's background has changed from the white it is in Qt5 and qt6 windows, to a grey that makes it look readonly. -
J james b-s has marked this topic as solved on
-
J james b-s has marked this topic as solved on
-
J james b-s has marked this topic as unsolved on
-
More information:
QApplication::setStyle("fusion") returns a non-null value indicating success, but it still doesn't do anything. As near as I can tell, there aren't any other calls to QApplication::setStyle in the applicationAdding -style fusion to the command line also does nothing
-
Maybe I don't understand what "fusion" means. According to the online documentation, fusion style should make the GUI for all the operating systems the same and make Qt6 look like Qt5. Maybe someone can correct me if I am wrong.
I set the style as I mentioned above. I added some checks to see what the style is by printing out QApplication::style()->objectName() to a trace file. The style gets changed to fusion and stays at fusion. But the GUI looks completely different in linux between Qt5 and Qt6. Windows looks the same between 5 and 6. And the GUI looks different between linux and windows.
Colors in linux are different from qt5, mostly having to do with backgrounds, the file browser is different.
-
Fusion is documented as using the same file browser in qt6 that was used in Qt5 (basically the windows file browser). Here is some code:
int main(int argc, char **argv) { const QStyle* pStyle2 = QApplication::setStyle("Fusion"); QApplication app(argc, argv); assert(pStyle2 != nullptr); QString fileName = QFileDialog::getOpenFileName( nullptr, // Parent widget (nullptr for standalone) "Open File", // Dialog title "/home", // Starting directory "All Files (*);;Text (*.txt)" // File filters (separated by ;; ) ); }This results in

-
Your example is using the file browser provided by the operating system in Qt5 and Qt6 when the platform integration is available for your os
-
Your example is using the file browser provided by the operating system in Qt5 and Qt6 when the platform integration is available for your os
@Christian-Ehrlicher Can you explain?
I was under the impression that fusion would change the file browser.
I'm also going to post an example of some code that shows how QEditLine format changes even though I have fusion set.
-
@Christian-Ehrlicher Can you explain?
I was under the impression that fusion would change the file browser.
I'm also going to post an example of some code that shows how QEditLine format changes even though I have fusion set.
@james-b-s said in Qt5 to Qt6 style changes:
Christian-Ehrlicher Can you explain?
I was under the impression that fusion would change the file browser.
Please read the documentation:https://doc.qt.io/qt-6/qfiledialog.html#getOpenFileName
On Windows, and macOS, this static function uses the native file dialog and not a QFileDialog. Note that the macOS native file dialog does not show a title bar.
-
Here is some code showing the original problem that I was working on
This code:
const QStyle* pStyle2 = QApplication::setStyle("Fusion"); QApplication app(argc, argv); assert(pStyle2 != nullptr); bool ok; QString text = QInputDialog::getText(nullptr, "Input Dialog", "User Name:", QLineEdit::Normal, "Default text", &ok);Produces the image on the left in linux and the image on the right in Qt5 and in windows on qt6

-
@james-b-s said in Qt5 to Qt6 style changes:
Christian-Ehrlicher Can you explain?
I was under the impression that fusion would change the file browser.
Please read the documentation:https://doc.qt.io/qt-6/qfiledialog.html#getOpenFileName
On Windows, and macOS, this static function uses the native file dialog and not a QFileDialog. Note that the macOS native file dialog does not show a title bar.
@Christian-Ehrlicher I've read the documentation. I've read tons of documentation. I'm trying to solve the problem where Qt6 changes the look and feel of linux builds. The documentation that I've been reading all say that the fusion style will solve my problem. Some of the information that I have found also seems to claim that it would solve the file browser problem also. Maybe that last is incorrect, but reading more documentation is not going to solve the problem.
As you can see in other stuff that I posted, It doesn't solve the problem with the style differences either.
-
The left input dialog is not fusion but another style.