Important: Please read the Qt Code of Conduct -

Android with qt widgets application error with pushbuttons

  • Hi,

    I need to develop an android app really fast and since I don't know well enough QML I'm trying to do it using c++ with Qt Widgets Application project.
    I simply make a dialog where there are some push buttons just to see if the ui is graphically nice for what I'm trying to do. Anyway when I click a push button it happens this:


    the push button "indietro" behaviour is really annoying and it still remains until I click another button, but then the button clicked behaves like button "indietro" in the image above.

    What can I do about this problem? Can anyone help me?
    Thanks in advance.

    I'm using Qt Creator 4.7.2, Android for X86 (GCC 4.9 Qt 5.11.1).

    android kit config:
    SDK Version: 26.1.1
    NDK Version: 10.4.0

    Local Device: Nexus_5X_API_28

  • Lifetime Qt Champion


    " behaviour is really annoying

    Im not really sure in what way :)
    Anyway, does it sort of stay down?
    Like a toggle?
    Or what is wrong with it?

    if yes to toogle, check if its
    "Checkable" property is on.

  • You are right, I didn't make that clear :)

    so what I don't like is that when I press the QPushButton the background becomes light blue and that black outline appears. Moreover these two things stay there not just while I'm pressing the QPushButton, but also when I release the button, and they stay there until I click anothe button, but then they appear on the other button and so on.
    It's ok if the background becomes light blue while I'm pressing the button, but when I release it should go away and return at the initial state. And I'd also like to get rid of the black outline.

    I hope I was more clear now.

  • Moderators

    I blieve you can takel that with the QStyleSheet

    QPushButton { outline: none; }

    should remove the focus rectangle

  • @J.Hilk Yes, it worked, thanks a lot.

    What about the background that remains also when I release the button? Do you have any hint?

  • Moderators

    äh, I think

    QPushButton:focus { background-color: green; }

    should get you on the right track. replace the background-color:green; with whatever the default normal behaviour is.

    I think there‘s a more elegant way, but I forgot.


    connect(myButton, &QPushButton:clicked, myButton, &QPushButton:clearFocus);

    will also work.

    Can‘t test it right now, I‘m on my Tablet 🙈

  • @J.Hilk said in Android with qt widgets application error with pushbuttons:

    connect(myButton, &QPushButton:clicked, myButton, &QPushButton:clearFocus);

    It works perfectly, tested right now!
    Thanks a lot for your help, you solved all of my problems!

Log in to reply