Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt for Python
  4. Why my QPushButtons are disable on Mac OS X whereas they are enable on Windows?

Why my QPushButtons are disable on Mac OS X whereas they are enable on Windows?

Scheduled Pinned Locked Moved Unsolved Qt for Python
12 Posts 4 Posters 1.9k Views 3 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • C Offline
    C Offline
    CentreFF
    wrote on last edited by
    #1

    Environment:

    Windows 10

    Mac OS X Mojave 10.14.6

    Python 3.7

    Pyqt5

    Problem:

    I am developping a software with Python. I am loading a UI with 'uic.loadUi'. Before to show all the buttons and labels, my program need to run some preparation tasks in a Qthread and show a loading gif while this preparation is working.

    Then it shows all the buttons and labels.

    To handle the displays of all the elements, I am using a JSON file which I update. It is useful to bulk change attributs of all element, and also it is not disturbing the Qthread when I want to change element.

    I made the method "DisplayFields()" which load the new attributs of elements.

    My problem is all my buttons are disable (blocked, I can't click on it) when I run my program on Mac OS X whereas they are all enable and working when I run my program on Windows 10.

    here is the code:

    class Ui(QtWidgets.QMainWindow):
        def __init__(self):
            global number_connected_phones
            super(Ui, self).__init__()
            uic.loadUi('ui/MyAppUI.Ui', self)
            # === We display the UI ==========
            self.show()
         
            self.DisplayFields()
    
    
        def DisplayFields(self):
            with open('ui/ui.json') as fjson:
                data_fields = json.load(fjson)
            fjson.close()
            
            for button_element in data_fields['buttons']:
                self.findChild(QPushButton, button_element['name']).setText(button_element['value'])
                self.findChild(QPushButton, button_element['name']).setStyleSheet(f"color: {button_element['color']}")
                self.findChild(QPushButton, button_element['name']).setStyleSheet(
                    f"background-color: {button_element['background-color']}")
                self.findChild(QPushButton, button_element['name']).setEnabled(button_element['enable'])
    
    
    if __name__ == '__main__':
        app = QtWidgets.QApplication(sys.argv)
        window = Ui()
        app.exec_()
    

    Here is the UI which you need to load with uic.loadUi:

    https://www.learnpyqt.com/courses/concurrent-execution/multithreading-pyqt-applications-qthreadpool/

    here is the Json file:

    https://drive.google.com/file/d/1TlAPW6GgjTQ-WvfmPKCvXw3RLv_iT_oo/view?usp=sharing

    Does anyone already faced this kind of issue with Mac OS X?

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by SGaist
      #2

      Hi,

      What version of PyQt are you using ?
      I vaguely remember some issues related to stylesheets (please check the bug report system).

      Try removing them to see if it changes the situation.

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • C Offline
        C Offline
        CentreFF
        wrote on last edited by
        #3

        Hi,

        Thanks for helping me.

        I use the PyQt5 5.15.0

        Your bug report link give me error message: DNS_PROBE_FINISHED_NXDOMAIN

        1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          Sorry ! Linked fix

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply
          0
          • C Offline
            C Offline
            CentreFF
            wrote on last edited by
            #5

            @SGaist said in Why my QPushButtons are disable on Mac OS X whereas they are enable on Windows?:

            stylesheets

            Thank you.

            I had a look and may have found some bugs corresponding to mine.
            But many of them don't concern the 5.15.0 version
            And even if I found one for the 5.15.0, I didn't see where was the solution.

            I am so sorry to bother you, I am a newbie, Could you guide me to the solution, please?

            1 Reply Last reply
            0
            • SGaistS Offline
              SGaistS Offline
              SGaist
              Lifetime Qt Champion
              wrote on last edited by
              #6

              Did you try the stylesheet removal I suggested ?

              Interested in AI ? www.idiap.ch
              Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

              1 Reply Last reply
              0
              • C Offline
                C Offline
                CentreFF
                wrote on last edited by
                #7

                Yes it works without the stylesheet. Thank you so much for your help.

                But now I have another problem. I can't change the color of my buttons. DO you have any idea how long it will take to fix this bug?

                1 Reply Last reply
                0
                • C Offline
                  C Offline
                  CentreFF
                  wrote on last edited by
                  #8

                  In fact the bug is not only for setstylesheet, but also for setEnabled.
                  Obviously, on MAC OS X, QT5 can't change the attributes of buttons.

                  You can reproduce the bug with the code I published here.

                  I hope you could fix this issue soon.

                  Thanks again for your help.

                  1 Reply Last reply
                  0
                  • JKSHJ Offline
                    JKSHJ Offline
                    JKSH
                    Moderators
                    wrote on last edited by
                    #9

                    Hi @CentreFF

                    There is a similar bug in Pyside 2 (Qt for Python) in the default macOS style plugin: https://bugreports.qt.io/browse/PYSIDE-695

                    The workaround in the report was to call app.setStyle('Fusion') in __main__ before you construct your window. Could you please test to see if it works for you?

                    Qt Doc Search for browsers: forum.qt.io/topic/35616/web-browser-extension-for-improved-doc-searches

                    1 Reply Last reply
                    1
                    • S Offline
                      S Offline
                      SimonSchroeder
                      wrote on last edited by
                      #10

                      This is a regression bug in Qt 5.15.0. The next release will be fine. That means that the easiest solution to your problem is to use an earlier version of Qt (I personally did go back to 5.13.2 as this is the version we are using on other platforms anyway). This solution has worked well for us.

                      JKSHJ 1 Reply Last reply
                      2
                      • S SimonSchroeder

                        This is a regression bug in Qt 5.15.0. The next release will be fine. That means that the easiest solution to your problem is to use an earlier version of Qt (I personally did go back to 5.13.2 as this is the version we are using on other platforms anyway). This solution has worked well for us.

                        JKSHJ Offline
                        JKSHJ Offline
                        JKSH
                        Moderators
                        wrote on last edited by
                        #11

                        @SimonSchroeder said in Why my QPushButtons are disable on Mac OS X whereas they are enable on Windows?:

                        This is a regression bug in Qt 5.15.0. The next release will be fine. That means that the easiest solution to your problem is to use an earlier version of Qt (I personally did go back to 5.13.2 as this is the version we are using on other platforms anyway). This solution has worked well for us.

                        Thanks, @SimonSchroeder. Do you have a link to the regression report or the fix?

                        Qt Doc Search for browsers: forum.qt.io/topic/35616/web-browser-extension-for-improved-doc-searches

                        1 Reply Last reply
                        0
                        • S Offline
                          S Offline
                          SimonSchroeder
                          wrote on last edited by SimonSchroeder
                          #12

                          https://bugreports.qt.io/browse/QTBUG-85487

                          It says that it is closed and fix version is 5.15.1.

                          1 Reply Last reply
                          0

                          • Login

                          • Login or register to search.
                          • First post
                            Last post
                          0
                          • Categories
                          • Recent
                          • Tags
                          • Popular
                          • Users
                          • Groups
                          • Search
                          • Get Qt Extensions
                          • Unsolved