Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QComboBox returns incorrect rect on Mac

QComboBox returns incorrect rect on Mac

Scheduled Pinned Locked Moved Unsolved General and Desktop
6 Posts 3 Posters 718 Views 1 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.
  • AndyBriceA Offline
    AndyBriceA Offline
    AndyBrice
    wrote on last edited by
    #1

    I am doing some custom painting inside a QComboBox. I call QComboBox::rect() to get the area to paint into inside paintEvent() in my derived class. This works fine on Windows. But is incorrect on Mac.

    What I want:

    0_1555067656190_2019-04-12_12-11-21.png
    What I get painting inside QComboBox::rect():

    0_1555067663931_2019-04-12_12-12-33.png
    The QRect returned is 30 pixels high, but the actual QComboBox is only 20 pixels high. I can adjust the QRect by a few pixels to get the correct area, but I am worried this fudge won't work on all versions of macOS (past and present). Is there a reliable way get the QRect?

    I use a QItemDelegate to paint the customized drop-down menu for the QComboBox and that works fine (QStyleOptionViewItem::rect is correct). But there doesn't seem to be way to use the delegate to paint the unclicked state.

    0_1555068032595_2019-04-12_12-19-15.png

    Any ideas?

    --
    Andy Brice
    http://www.hyperplan.com

    jsulmJ 1 Reply Last reply
    0
    • AndyBriceA AndyBrice

      I am doing some custom painting inside a QComboBox. I call QComboBox::rect() to get the area to paint into inside paintEvent() in my derived class. This works fine on Windows. But is incorrect on Mac.

      What I want:

      0_1555067656190_2019-04-12_12-11-21.png
      What I get painting inside QComboBox::rect():

      0_1555067663931_2019-04-12_12-12-33.png
      The QRect returned is 30 pixels high, but the actual QComboBox is only 20 pixels high. I can adjust the QRect by a few pixels to get the correct area, but I am worried this fudge won't work on all versions of macOS (past and present). Is there a reliable way get the QRect?

      I use a QItemDelegate to paint the customized drop-down menu for the QComboBox and that works fine (QStyleOptionViewItem::rect is correct). But there doesn't seem to be way to use the delegate to paint the unclicked state.

      0_1555068032595_2019-04-12_12-19-15.png

      Any ideas?

      --
      Andy Brice
      http://www.hyperplan.com

      jsulmJ Offline
      jsulmJ Offline
      jsulm
      Lifetime Qt Champion
      wrote on last edited by
      #2

      @AndyBrice Just an idea: could it be related to High DPI scaling?

      https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • AndyBriceA Offline
        AndyBriceA Offline
        AndyBrice
        wrote on last edited by
        #3

        It might be related to high DPI. I am on a Mac Retina display.

        --
        Andy Brice
        http://www.hyperplan.com

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

          Hi,

          What version of Qt are you using ?

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

          AndyBriceA 1 Reply Last reply
          0
          • SGaistS SGaist

            Hi,

            What version of Qt are you using ?

            AndyBriceA Offline
            AndyBriceA Offline
            AndyBrice
            wrote on last edited by
            #5

            @SGaist I am using Qt 5.12.0 on Mac.

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

              Did you check with a more recent version ?

              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

              • Login

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