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()); rect.moveCenter(devRect.center()); painter.drawPixmap(rect.topLeft(), bkgnd_scaled); }
Cheers,
Nick
-
For anyone wondering what the solution was, I had unused
QToolbar
andQstatusBar
, 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
-
Hi,
Yes you can, but first check whether there's already something about this behaviour.
-
Take a look at the bug report system