Important: Please read the Qt Code of Conduct -

QPushButton differences between Qt 5.9.1 and Qt 5.14?

  • I have created a trivial app with one pushbutton using the UI designer in Qt Creator. It has on and off icons assigned, is checkable, and calls a single one line function:

    void MainWindow::on_pushButton_toggled(bool checked)
        qDebug() << "Checked =" << checked;

    I have two platforms setup: Ubuntu 16.04, Qt 5.9, Qt Creator 4.3 and Ubuntu 18.04, Qt 5.14, Qt Creator 4.11.

    On both platforms I can check the "checked" box in the designer and see both icons alternately so I know that I am pointing to the right place for the icon image files but when I run the application I get different results on the two platforms...

    On the older system everything works as expected: Each time I click the button the icon toggles and I get a debug message.

    On the newer system, the icon doesn't change. The background switches between two shades of gray and I get a debug message but I never see the second icon.

    Is this a bug or am I missing something...?

  • Lifetime Qt Champion

    Upgrade to 5.15. There was a bug in the fusion theme.

  • But then I read this:
    which seems to say "we don't recommend it"
    I think I will live with a small bug for now rather than risk creating a big problem for myself. At least I know I'm not doing something stupid (this time at least!)
    Thanks, I will mark this solved.

  • Lifetime Qt Champion

    @mdresser said in QPushButton differences between Qt 5.9.1 and Qt 5.14?:

    which seems to say "we don't recommend it"


  • @Christian-Ehrlicher

    This is what I was reading. I realize that there is probably a safe way to do it but I am not enough of a Linux expert to know where the traps are and am not looking for adventure... I'll live with the bug until I'm doing a fresh install.

    You can install Qt to system folders, or add symlinks in /usr/lib pointing to your newer version.

    But I don't recommend it at all. Qt shipped with given distribution has been compiled and tested to work with other apps shipped by the distro. If you swap Qt version you may run into a myriad of problems, crashes etc. in many random apps.

    Best approach: find a PPA which ships updated KDE & Qt (KDE Neon comes to mind here) or switch to a different distribution which ships with modern enough Qt.

    mariozio 23 Oct 2020, 06:30

    @sierdzio said in How to upgrade Qt from 5.14.2 to 5.15.1 ?:

    PPA which ships updated KDE & Qt (KDE Neon

    what about to compile them from scratch like this ?
    sierdzio Moderators 23 Oct 2020, 06:35

    Even there, they recommend installing to /opt ;-)

    But look further down, they provide installations on how to tell the system where to look for Qt instead of scanning /usr.

    Feel free to try it, sure. Or custom compilation - that's surely possible. My warning still stands - you are likely to break your system. It's a good training and adventure, though :-) Please report back if you make any progress.

  • Follow-up:
    After noting that the PB background colour changed slightly when clicked, I added this when creating the pushbutton:>setStyleSheet("QPushButton:checked { background-color : green;}");   // work-around for Qt 5.14 bug

    This made the checked state more obvious and curiously, the correct checked icon also appeared.

Log in to reply