Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. Why does QPushButton not respect absolute pixel size?
QtWS25 Last Chance

Why does QPushButton not respect absolute pixel size?

Scheduled Pinned Locked Moved Solved Mobile and Embedded
pyqt4qpushbuttonsizelayout issues
5 Posts 2 Posters 966 Views
  • 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
    cerr
    wrote on 6 Apr 2021, 18:18 last edited by
    #1

    I'm working on an application that's running on an embedded device with a touch screen LCD. For my dev setup, I have setup a Xephyr window with the matchbox WM at the same resolution as the LCD on the end device (1280x800).

    I have developed a custom drop-down menu that will expand downwards and show select buttons, on my dev system this looks as designed) something like this:

    7b9bfde6-56c0-4a03-bdc4-53dfece5e858-image.png

    Where on the end device, the button for some reason fills the whole window as can be seen here:

    3b3982d3-009e-4222-b439-423173342edb-image.png

    The functionality seems there but even though fix pixel sizes are used for the button size, it seems to take up the space of the whole window. The "drop-down" buttons are created from a list like:

    btn_size = QtCore.QSize(206,57)
    
            for n in btnlist:
                _name = str(n)
                self.drpbtns.append(QtGui.QPushButton(_name))
                self.drpbtns[i].clicked.connect(lambda checked, v=_name: func(v))
                self.drpbtns[i].setFixedSize(btn_size) 
                self.drpbtns[i].move(x,y+(i*(self.drpbtns[i].height()-1)))
                self.drpbtns[i].setStyleSheet('background-color: rgb(255,255,255); \
                                               border: 1px solid rgb(216,216,216); \
                                               color: rgb(92,92,92); \
                                               font: bold 22pt "Avenir"')
                self.drpbtns[i].setFlat(True)
    
    
                i = i+1
    

    Why would the button not respect the FixedSize constraints?
    I have not been able to create a simple application that duplicates the problem as the problem only appears on the target device (and not on my dev setup - which is odd as well - I'm running my dev setup in a container attempting to create an env as similar as possible(Ubuntu Xenial 16.04, PyQt4, matchbox WM). Fix pixel sizes can be used as there is no need to support different window sizes/positions as the single screen is all the UI will show.

    I have already started a thread regarding this on Stackoverflow and I was suggested to replace .resize(btn_size) with .setFixedSize(btn_size) which didn't yield the expected effect though. As for the two threads, I'll keep them in sync, i.e. I'll sync any updates to both threads!

    Thanks for any assistance!

    1 Reply Last reply
    0
    • S SGaist
      6 Apr 2021, 18:29

      Hi,

      Do you mean you have Matchbox running as well on your device ?

      C Offline
      C Offline
      cerr
      wrote on 6 Apr 2021, 18:40 last edited by cerr 4 Jun 2021, 18:43
      #3

      @SGaist Yes, Matchbox is running as well on the device.
      I think I just figured the issue out, it's because my drop down buttons were missing the parent.
      GFurether testing has to be done but a quick test with using self.drpbtns.append(QtGui.QPushButton(_name,self.parent)) instead has shown progress! I found the hint for this here: https://forum.qt.io/topic/78752/how-to-place-widgets-by-specifying-positions-in-qframe

      1 Reply Last reply
      0
      • S Offline
        S Offline
        SGaist
        Lifetime Qt Champion
        wrote on 6 Apr 2021, 18:29 last edited by
        #2

        Hi,

        Do you mean you have Matchbox running as well on your device ?

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

        C 1 Reply Last reply 6 Apr 2021, 18:40
        1
        • S SGaist
          6 Apr 2021, 18:29

          Hi,

          Do you mean you have Matchbox running as well on your device ?

          C Offline
          C Offline
          cerr
          wrote on 6 Apr 2021, 18:40 last edited by cerr 4 Jun 2021, 18:43
          #3

          @SGaist Yes, Matchbox is running as well on the device.
          I think I just figured the issue out, it's because my drop down buttons were missing the parent.
          GFurether testing has to be done but a quick test with using self.drpbtns.append(QtGui.QPushButton(_name,self.parent)) instead has shown progress! I found the hint for this here: https://forum.qt.io/topic/78752/how-to-place-widgets-by-specifying-positions-in-qframe

          1 Reply Last reply
          0
          • S Offline
            S Offline
            SGaist
            Lifetime Qt Champion
            wrote on 6 Apr 2021, 18:43 last edited by
            #4

            Without parent, they are top level widgets and depending on your WM settings will be shown full screen.

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

            C 1 Reply Last reply 7 Apr 2021, 18:43
            1
            • S SGaist
              6 Apr 2021, 18:43

              Without parent, they are top level widgets and depending on your WM settings will be shown full screen.

              C Offline
              C Offline
              cerr
              wrote on 7 Apr 2021, 18:43 last edited by
              #5

              @SGaist Yes Thank! It all makes sense now!

              1 Reply Last reply
              0

              5/5

              7 Apr 2021, 18:43

              • Login

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