Qt World Summit: Submit your Presentation

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

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

    Screenshot from mac:

    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());
        painter.drawPixmap(rect.topLeft(), bkgnd_scaled);



  • 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">
     <widget class="QMainWindow" name="imageSelector" >
      <property name="geometry" >
      <property name="windowTitle" >
      <widget class="QMenuBar" name="menuBar" />
      <widget class="QToolBar" name="mainToolBar" /> #CULPRIT
      <widget class="QWidget" name="centralWidget" />
      <widget class="QStatusBar" name="statusBar" /> #CULPRIT
     <layoutDefault spacing="6" margin="11" />

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



  • Lifetime Qt Champion


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

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

  • Lifetime Qt Champion

    Take a look at the bug report system

Log in to reply