Qt6 platform rendering issues on Ubuntu 22.04
-
wrote on 19 Oct 2023, 10:12 last edited by
After updating my C++ desktop application to build with Qt 6.5, I noticed strange changes in the rendering of the widgets. For example, there are no window borders, and setting
enabled = false
for labels, etc. does not make them appear disabled. I have to add a command-line option-platform xcb
to run my app in order to see the title bar.Here are the screenshots of the different ways the main window is rendered for comparison:
-
Built with Qt 6.5, default appearance (no command-line option) ... notice how there is no window border:
Notice that on Qt 5, my "To do" list is nicely set to disabled gray look, whereas all labels look enabled with Qt 6 in both renderings.
What is the least intrusive way of making the newer versions look like the older ones?
-
wrote on 19 Oct 2023, 10:16 last edited by
-
Here is a screenshot with an active database in the app built with Qt 5.15, showing the "To do" list with different stages enabled and disabled:
Hi,
Do you have the same issue if you use the fusion style ?
By the way, which desktop environment are you using ?
-
Hi,
Do you have the same issue if you use the fusion style ?
By the way, which desktop environment are you using ?
wrote on 20 Oct 2023, 11:55 last edited by@SGaist Thanks for looking at this. I am basically running a default desktop which Ubuntu 22.04 has configured. I don't really know what I am doing here, since I never changed anything. But I saw somewhere references to environment variables beginning with
XDG_...
, so here are the results of a few of those:bob@bobs-laptop:~$ echo $XDG_SESSION_TYPE wayland bob@bobs-laptop:~$ echo $XDG_SESSION_DESKTOP ubuntu bob@bobs-laptop:~$ echo $XDG_CURRENT_DESKTOP ubuntu:GNOME
If I give this option on the command line:
-patform xcb
as mentioned above, are there any options I can add after that? I looked all over but could not find any documentation about what the allowed options are, except for-platform windows
which has a lot of extra options.As to
fusion
, I get a fatal error when I put ? -platform fusion` on the command line:This application failed to start because no Qt platform plugin could be initialized. Reinstalling the application may fix this problem. Available platform plugins are: xcb, offscreen, minimal, vkkhrdisplay, eglfs, vnc, linuxfb, wayland, minimalegl, wayland-egl.
What do I need to do in order to get
fusion
to work? -
Hi,
Do you have the same issue if you use the fusion style ?
By the way, which desktop environment are you using ?
wrote on 20 Oct 2023, 14:03 last edited by@SGaist I found out how to set the "Fusion" style here in another forum thread.
So I added this line to my
main()
function right after creating the instance of QApplication:qApp->setStyle(QStyleFactory::create("Fusion"));
It doesn't have any effect, AFAICT.
-
@SGaist I found out how to set the "Fusion" style here in another forum thread.
So I added this line to my
main()
function right after creating the instance of QApplication:qApp->setStyle(QStyleFactory::create("Fusion"));
It doesn't have any effect, AFAICT.
wrote on 20 Oct 2023, 14:24 last edited by JoeCFD@Robert-Hairgrove I just wrote a small test program to confirm that qlabel is greyed out if it is disabled. Qt: 6.5.2 and OS: Ubuntu 22.04.
-
@Robert-Hairgrove I just wrote a small test program to confirm that qlabel is greyed out if it is disabled. Qt: 6.5.2 and OS: Ubuntu 22.04.
wrote on 20 Oct 2023, 15:15 last edited by@JoeCFD Thanks ... would you mind sharing your code with us? :)
-
@JoeCFD Thanks ... would you mind sharing your code with us? :)
wrote on 20 Oct 2023, 16:40 last edited by JoeCFD@Robert-Hairgrove
main.cpp#include "helpwidget.h" #include <QApplication> int main( int argc, char *argv[] ) { QApplication app(argc, argv); auto widget = new HelpWidget; widget->show(); return app.exec(); }
helpwidget.h
#ifndef HELPWIDGET_H #define HELPWIDGET_H #include <QWidget> //! [0] class HelpWidget : public QWidget { Q_OBJECT public: HelpWidget(QWidget *parent = nullptr); }; //! [0] #endif // HelpWidget_H
helpwidget.cpp
#include <QVBoxLayout> #include <QLabel> #include <QPushButton> #include "helpwidget.h" HelpWidget::HelpWidget( QWidget * parent ) : QWidget(parent) { auto layout = new QVBoxLayout( this ); setMinimumSize( 400, 400 ); auto label = new QLabel( "Dis/enabled test", this ); auto button = new QPushButton( "Press", this ); layout->addWidget( label ); layout->addWidget( button ); connect( button, &QPushButton::pressed, [=](){ auto isEnabled = label->isEnabled(); label->setEnabled( !isEnabled ); } ); }
-
@Robert-Hairgrove
main.cpp#include "helpwidget.h" #include <QApplication> int main( int argc, char *argv[] ) { QApplication app(argc, argv); auto widget = new HelpWidget; widget->show(); return app.exec(); }
helpwidget.h
#ifndef HELPWIDGET_H #define HELPWIDGET_H #include <QWidget> //! [0] class HelpWidget : public QWidget { Q_OBJECT public: HelpWidget(QWidget *parent = nullptr); }; //! [0] #endif // HelpWidget_H
helpwidget.cpp
#include <QVBoxLayout> #include <QLabel> #include <QPushButton> #include "helpwidget.h" HelpWidget::HelpWidget( QWidget * parent ) : QWidget(parent) { auto layout = new QVBoxLayout( this ); setMinimumSize( 400, 400 ); auto label = new QLabel( "Dis/enabled test", this ); auto button = new QPushButton( "Press", this ); layout->addWidget( label ); layout->addWidget( button ); connect( button, &QPushButton::pressed, [=](){ auto isEnabled = label->isEnabled(); label->setEnabled( !isEnabled ); } ); }
wrote on 20 Oct 2023, 18:24 last edited by@JoeCFD Thanks!
Could you also please post the contents of the *.pro file (or CMake project file) that you used to build this?
-
@JoeCFD Thanks!
Could you also please post the contents of the *.pro file (or CMake project file) that you used to build this?
wrote on 20 Oct 2023, 18:52 last edited by JoeCFD@Robert-Hairgrove There you.
testlabel.proQT += widgets HEADERS += \ helpwidget.h SOURCES += \ helpwidget.cpp \ main.cpp
-
@Robert-Hairgrove There you.
testlabel.proQT += widgets HEADERS += \ helpwidget.h SOURCES += \ helpwidget.cpp \ main.cpp
wrote on 20 Oct 2023, 19:11 last edited by@JoeCFD Your code builds and runs OK, but when I click on the "Press" button, the label does not change its appearance.
Please post the results of the following commands run in a terminal:
echo $XDG_SESSION_TYPE echo $XDG_SESSION_DESKTOP echo $XDG_CURRENT_DESKTOP
Also:
echo $QT_QPA_PLATFORM
Thank you!
-
@JoeCFD Your code builds and runs OK, but when I click on the "Press" button, the label does not change its appearance.
Please post the results of the following commands run in a terminal:
echo $XDG_SESSION_TYPE echo $XDG_SESSION_DESKTOP echo $XDG_CURRENT_DESKTOP
Also:
echo $QT_QPA_PLATFORM
Thank you!
wrote on 20 Oct 2023, 19:38 last edited by@Robert-Hairgrove
x11
Lubuntu
LXQt
empty -
Here is a screenshot with an active database in the app built with Qt 5.15, showing the "To do" list with different stages enabled and disabled:
wrote on 20 Oct 2023, 19:42 last edited by@Robert-Hairgrove
@SGaist understands this much better than I do, but is your picture #2 (no borders and Qt6.5) somehow "wayland"? Which might not have/do the effects of x11/xcb? -
@Robert-Hairgrove
@SGaist understands this much better than I do, but is your picture #2 (no borders and Qt6.5) somehow "wayland"? Which might not have/do the effects of x11/xcb?wrote on 20 Oct 2023, 19:43 last edited by@JonB Yes, it is wayland if I do not set
"-platform xcb"
as a command line option. -
wrote on 20 Oct 2023, 19:45 last edited by
I forgot to add that the precise version of Qt I have is 6.5.3 which was installed automatically by the Qt Creator maintenance tool.
-
I forgot to add that the precise version of Qt I have is 6.5.3 which was installed automatically by the Qt Creator maintenance tool.
wrote on 20 Oct 2023, 19:47 last edited by JoeCFD@Robert-Hairgrove I guess the problem should be gone if you switch to X11. Do you have to use Wayland? Wayland is the default setting in Ubuntu 22.04.
-
@Robert-Hairgrove I guess the problem should be gone if you switch to X11. Do you have to use Wayland? Wayland is the default setting in Ubuntu 22.04.
wrote on 20 Oct 2023, 19:50 last edited by -
wrote on 20 Oct 2023, 19:52 last edited by JoeCFD
@Robert-Hairgrove logout your account. You can see a settings icon on the login screen and click the setting icon to select Xorg. Then log in and you will be good.
-
@Robert-Hairgrove logout your account. You can see a settings icon on the login screen and click the setting icon to select Xorg. Then log in and you will be good.
wrote on 20 Oct 2023, 20:30 last edited by@JoeCFD Thanks.
I logged in again with XOrg, but unfortunately the problem persists.
-
@Robert-Hairgrove logout your account. You can see a settings icon on the login screen and click the setting icon to select Xorg. Then log in and you will be good.
wrote on 20 Oct 2023, 20:31 last edited by@JoeCFD BTW, what is "LXQt"?
1/31