Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Widget on Mac has a top and bottom border that is drawn on top of everything
Qt 6.12 LTS is out! See what's new in the release blog

Widget on Mac has a top and bottom border that is drawn on top of everything

Scheduled Pinned Locked Moved Solved General and Desktop
5 Posts 2 Posters 1.2k 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.
  • X Offline
    X Offline
    XapaJIaMnu
    wrote on last edited by XapaJIaMnu
    #1

    Hey guys,

    Apologies for the spam "HELP WITH MAC" topics.

    I have a simple widget that acts as an image viewer. The widget window displays images as expected on Linux and Windows, but on Mac, I have top and bottom borders that get drawn over the image and I have no idea how to get rid of them.

    Screenshot from linux:
    correct_image

    Screenshot from mac:
    correct_image

    As you can see on the mac version, there is a border on the top and the bottom half of the image. How do I get rid of it?

    Here's the related code. I do not definite any style for the widget, I used the default created and then resize the window in my code as needed.

    void imageSelector::paintEvent(QPaintEvent *) {
        QPainter painter(this);
        bkgnd_scaled = bkgnd.scaled(this->size(), Qt::KeepAspectRatio);
        QRect rect = bkgnd_scaled.rect();
        QRect devRect(0, 0, painter.device()->width(), painter.device()->height());
        rect.moveCenter(devRect.center());
        painter.drawPixmap(rect.topLeft(), bkgnd_scaled);
    }
    

    Cheers,

    Nick

    1 Reply Last reply
    0
    • X Offline
      X Offline
      XapaJIaMnu
      wrote on last edited by
      #2

      For anyone wondering what the solution was, I had unused QToolbar and QstatusBar, which were invisible on Linux and Windows, but appeared on Mac. Removing them from the .ui file fixed the issue:

      <ui version="4.0">
       <class>imageSelector</class>
       <widget class="QMainWindow" name="imageSelector" >
        <property name="geometry" >
         <rect>
          <x>0</x>
          <y>0</y>
          <width>400</width>
          <height>300</height>
         </rect>
        </property>
        <property name="windowTitle" >
         <string>imageSelector</string>
        </property>
        <widget class="QMenuBar" name="menuBar" />
        <widget class="QToolBar" name="mainToolBar" /> #CULPRIT
        <widget class="QWidget" name="centralWidget" />
        <widget class="QStatusBar" name="statusBar" /> #CULPRIT
       </widget>
       <layoutDefault spacing="6" margin="11" />
       <pixmapfunction></pixmapfunction>
       <resources/>
       <connections/>
      </ui>
      

      Should I open a bug for the inconsistent cross-platform behaviour?

      Cheers,

      Nick

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

        Hi,

        Yes you can, but first check whether there's already something about this behaviour.

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

        X 1 Reply Last reply
        0
        • SGaistS SGaist

          Hi,

          Yes you can, but first check whether there's already something about this behaviour.

          X Offline
          X Offline
          XapaJIaMnu
          wrote on last edited by
          #4

          @SGaist I couldn't find anything about that. Where should I look for that information?

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

            Take a look at the bug report system

            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
            • Unsolved