Qt6 platform rendering issues on Ubuntu 22.04
-
@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.
@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.
@JoeCFD Thanks ... would you mind sharing your code with us? :)
-
@JoeCFD Thanks ... would you mind sharing your code with us? :)
@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 ); } ); }
@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?
@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
@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!
@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:
-
@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?@JonB Yes, it is wayland if I do not set
"-platform xcb"
as a command line option. -
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.
@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.
-
@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.
@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.
@JoeCFD BTW, what is "LXQt"?
-
@JoeCFD Thanks.
I logged in again with XOrg, but unfortunately the problem persists.
@Robert-Hairgrove did you do:
make distclean
qmake
make
run -
@JoeCFD BTW, what is "LXQt"?
-
OK, this must be a bug introduced in 6.5.
I installed Qt versions 6.2.4, 6.3.2, 6.4.3 in addition to 6.5.3 and 6.6.0. Up to 6.4.3, the controls are displayed correctly (enabled=black text, disabled=gray).
Beginning with 6.5.3 and also 6.6.0, the problem arises (everything displays as if enabled, regardless of state).
Looks like I need to file a bug report, but I don't have time today to do it today.
-
OK, this must be a bug introduced in 6.5.
I installed Qt versions 6.2.4, 6.3.2, 6.4.3 in addition to 6.5.3 and 6.6.0. Up to 6.4.3, the controls are displayed correctly (enabled=black text, disabled=gray).
Beginning with 6.5.3 and also 6.6.0, the problem arises (everything displays as if enabled, regardless of state).
Looks like I need to file a bug report, but I don't have time today to do it today.
@Robert-Hairgrove
As before, this is only a suggestion. I wonder whether Qt 6.5+ has introduced some change in default so that it is using Wayland over Xorg? And that might be the cause of the changed look? I came across e.g. Qt 6.5 Adding Wayland Native Interfaceand now set to come with Qt 6.5 is support for a Wayland native interface for application developers wanting to interact directly with Wayland object handles.
Did Qt 6.5 become more preferentially Wayland-y than earlier?
-
@Robert-Hairgrove
As before, this is only a suggestion. I wonder whether Qt 6.5+ has introduced some change in default so that it is using Wayland over Xorg? And that might be the cause of the changed look? I came across e.g. Qt 6.5 Adding Wayland Native Interfaceand now set to come with Qt 6.5 is support for a Wayland native interface for application developers wanting to interact directly with Wayland object handles.
Did Qt 6.5 become more preferentially Wayland-y than earlier?
@JonB I get the same result regardless of whether I log in using Xorg or Wayland, as far as the enabled/disabled bug is concerned.
If I log in with Xorg, Qt seems to load
xcb
, otherwisewayland
is used. I can also specify either platform on the command line; this will change the way some things are displayed, e.g. window border or not, but in every case the bug described above still persists.BTW I also made sure that the
Qt Wayland Compositor
module was included in all of the installations of Qt. I thought not having that installed might have led to the error, but apparently it makes no difference.