Details
-
Bug
-
Resolution: Unresolved
-
P2: Important
-
None
-
5.15.0
-
None
-
Qt 5.15.0, CMake 3.17, Qt Creator 4.12.3
Description
I was working on an application based on 3 panels (status bar, side bar, content) and I found out that when I create a custom widget that inherits from QWidget and uses setFixedSize() and setStyleSheet() nothing is rendered.
Everything is fine and it renders a 1280x60 rectangle (see attached screenshot 1) using a QWidget directly:
QWidget * bar1 = new QWidget(this);
bar1->setFixedSize(1280, 60);
bar1->setStyleSheet(QString("background: #333333;"));
Whereas this renders nothing (see attached screenshot 2):
StatusBar * bar1 = new StatusBar(this);
bar1->setFixedSize(1280, 60);
bar1->setStyleSheet(QString("background: #333333;"));
And StatusBar simply inherits from QWidget without adding any code:
#include <QWidget>
class StatusBar : public QWidget
{
Q_OBJECT
public:
explicit StatusBar(QWidget * parent = nullptr);
};
I would expect to get exactly the same result, but apparently something is not working when inheriting from a QWidget.
A workaround is to re-implement the paintEvent() function, but this is still unexpected and wrong behavior.
I have attached an example project for reference.