Label does not resize with resizeEvent
Unsolved
General and Desktop
-
lbl = new QLabel( ui->centralWidget); lbl->setStyleSheet("Background-color:pink");
How do i resize this label using resizeEvent . When i put this code in void Mainwindow :: resizeEvent(QreseizeEvent *evt) ; it stays the same. The size does not change.
Please give me a proper explanation about resize event.
Thank you.
-
@ronyNS said:
resizeEvent
http://doc.qt.io/qt-5/qwidget.html#resizeEvent
Its called when mainwindow change size.
To size a qlabel
you do
lbl->resize(x,y)
or
lbl->setGeometry(0,0, event->size().width(), event->size().height());
to use the mainwindow values -
It fits the window size , but does not resize when i maximize the window
My code
Void MainWindow :: resizeEvent(QResizeEvent *event) { lbl = new QLabel (ui->centralWidget); Int x = MainWindow::size().height(); Int y = MainWindow::size().width(); lbl->resize(x,y); MainWindow::resizeEvent(evt); }