Visual issue with QRadioButton on Android – no selection dot shown
-
wrote 19 days ago last edited by
The clicked signal is being received correctly, but the QRadioButtons are not visually showing as selected the dot inside the button does not appear. This seems to be a rendering or focus issue, and it occurs especially on mobile devices, particularly on Android.
#include <QApplication> #include <QWidget> #include <QRadioButton> #include <QVBoxLayout> #include <QTimer> #include <QDebug> int main(int argc, char *argv[]) { QApplication app(argc, argv); QApplication::setStyle("Fusion"); QWidget window; QVBoxLayout* layout = new QVBoxLayout; QRadioButton* radio1 = new QRadioButton("Option 1"); QRadioButton* radio2 = new QRadioButton("Option 2"); // Kein QButtonGroup - versuch es direkt ohne den ButtonGroup. layout->addWidget(radio1); layout->addWidget(radio2); window.setLayout(layout); // Optional: Debugging-Ausgabe, um zu überprüfen, ob der Button korrekt aktiviert wird. QObject::connect(radio1, &QRadioButton::clicked, []() { qDebug() << "Option 1 clicked!"; }); QObject::connect(radio2, &QRadioButton::clicked, []() { qDebug() << "Option 2 clicked!"; }); // Optional: einen Button nachträglich auswählen QTimer::singleShot(100, [=]() { radio1->setChecked(true); qDebug() << "Option 1 should be checked now!"; }); window.resize(300, 150); window.show(); return app.exec(); }
Has anyone encountered this before? Any suggestions on how to fix or work around it?
-
The clicked signal is being received correctly, but the QRadioButtons are not visually showing as selected the dot inside the button does not appear. This seems to be a rendering or focus issue, and it occurs especially on mobile devices, particularly on Android.
#include <QApplication> #include <QWidget> #include <QRadioButton> #include <QVBoxLayout> #include <QTimer> #include <QDebug> int main(int argc, char *argv[]) { QApplication app(argc, argv); QApplication::setStyle("Fusion"); QWidget window; QVBoxLayout* layout = new QVBoxLayout; QRadioButton* radio1 = new QRadioButton("Option 1"); QRadioButton* radio2 = new QRadioButton("Option 2"); // Kein QButtonGroup - versuch es direkt ohne den ButtonGroup. layout->addWidget(radio1); layout->addWidget(radio2); window.setLayout(layout); // Optional: Debugging-Ausgabe, um zu überprüfen, ob der Button korrekt aktiviert wird. QObject::connect(radio1, &QRadioButton::clicked, []() { qDebug() << "Option 1 clicked!"; }); QObject::connect(radio2, &QRadioButton::clicked, []() { qDebug() << "Option 2 clicked!"; }); // Optional: einen Button nachträglich auswählen QTimer::singleShot(100, [=]() { radio1->setChecked(true); qDebug() << "Option 1 should be checked now!"; }); window.resize(300, 150); window.show(); return app.exec(); }
Has anyone encountered this before? Any suggestions on how to fix or work around it?
@thomasGl QtWidgets are not actively developed (more in maintenance mode), this is especially problematic for mobile platforms. You should consider switching to QML which is better suited for mobile platforms.
-
wrote 19 days ago last edited by thomasGl
-
Is it possible to use Qt Quick together with a form-based editor, where you can drag and drop UI components visually similar to how it's done in Qt Widgets with .ui files? The Buttons work with qt Quick.
@thomasGl You can do that with https://doc.qt.io/qtdesignstudio/
2/4