QDial does not expand
-
Dear all,
I made a custom class that hinerited from QDial and called PowerDial.
I don't understand because does not growing up to sizeHint if the policy is MinimumExpanding.void Run::makePowerDial(void) { rightLayoutPower = new QVBoxLayout(); QLabel* label = new QLabel(Translator::GetInstance().get("power")); label->setAlignment(Qt::AlignCenter); PowerDial* powerDial = new PowerDial(40, 20); powerDial->setValue(5); powerDial->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding); rightLayoutPower->addWidget(powerDial, 9, Qt::AlignCenter); rightLayoutPower->addWidget(label, 1, Qt::AlignCenter); }Inside the class are overridden the funcions:
int PowerDial::heightForWidth(int width) const { return width; } QSize PowerDial::sizeHint() const { return QSize(200, 200); } QSize PowerDial::minimumSizeHint() const { return QSize(100, 100); } bool PowerDial::hasHeightForWidth() const { return true; } void PowerDial::resizeEvent(QResizeEvent *event) { }
-
Hi
What happens if you remove the empty resizeEvent ? -
Nothing!
If the sizeHint is greater respect the available area the widget is reduced correctly but if his sizeHint is smaller then the available area It keep the sizeHint area.
-
Simple check - created an empty widget, added a QDial and put it in a QGridLayout - it's expanding to the widgets size. Tested with QtDesigner and QtCreator (both Qt5.15) . So there must be something wrong on your side. Please provide a minimal, compilable example.
-
What Qt style do you use?
-
What Qt style do you use?
The fusion style
-
Also works fine for me with the fusion style on linux with Qt5.15. Please exactly follow my testcase to see if this works for you or not.
-
Also works fine for me with the fusion style on linux with Qt5.15. Please exactly follow my testcase to see if this works for you or not.
If the dial is used in a new empty project it works fine!
What I could be have broken in my project?
-
If the dial is used in a new empty project it works fine!
What I could be have broken in my project?
@Simof said in QDial does not expand:
What I could be have broken in my project?
Reduce your project until it works, or create a testaplication and try to add your stuff until it no longer works - basic programming stuff :)
