I have an application in Qt and whenever I want to minimize the application I use
this->showMinimized();
However this line will not work inside a child widget (other than in the child's constructor where 'parent' is available).
Other than setting up a signal and slot, is there a way to minimize the application from a child widget? I'm trying to avoid signals and slots as I'm starting to have a tons of them.
Thanks in advance!
You can set the window state to minimized. If the parent widget of your child widget is your application main window you should call in your child widget :
this->parentWidget()->setWindowState(Qt::WindowMinimized);
It is also possible to save a pointer to the main window in the constructor of your child widget :
QWidget * myParent;
MyWidget::MyWidget(QWidget *parent) :
QWidget(parent),
ui(new Ui::MyWidget)
{
ui->setupUi(this);
this->myParent = parent;
...
}
and call whenever you want to minimize the application :
this->myParent->setWindowState(Qt::WindowMinimized);
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments