Home > Mobile >  Questions about the location of the two dialog boxes
Questions about the location of the two dialog boxes

Time:05-27

Dear bosses, in a one of the main dialog, please click on the button control, pop-up a child dialogs, how can let the child dialog box is displayed in the main window is a central location?
The code is as follows:
Public mainDialog: public QDialog
{
Q_OBJECT
Public:
MainDialog (QDialog * parent=nullptr);
~ mainDialog ();

Private slots:
Void clickedOnSubDialog ();

Private:
QPushButton * m_button;
};

Public subDialog: public QDialog
{
Q_OBJECT
Public:
SubDialog (QDialog * parent=nullptr);
~ subDialog ();
}


MainDialog: : mainDialog (QDialog * parent) : QDialog (parent)
{
M_button=new QPushButton (QString (" next dialog "), this);
M_button - & gt; The resize (40, 30);
M_button - & gt; Move (this - & gt; Width () * 50/100, this - & gt; Height () * 40/100);
The connect (m_button, & amp; QPushButton: : clicked, this, & amp; MainDialog: : clickedOnSubDialog);
}

MainDialog: : ~ mainDialog ()
{

}

Void mainDialog: : clickedOnSubDialog ()
{
SubDialog DLG.
Int res=DLG. The exec ();
If (res!=QDialog: : Accepted)
{
return ;
}
}

SubDialog: : subDialog (QDialog * parent) : QDialog (parent)
{

}

SubDialog: : ~ subDialog ()
{

}

,, can you tell me the code above is what m_button, click on the button pop up child dialogs have not in the middle of the mainDialog is show? Don't know is there any way to make it appear in the main dialog per click locations are right in the middle?

CodePudding user response:

DLG manually move to the middle first, then the exec

CodePudding user response:

reference 1/f, it is a nice nickname response:
DLG manually move to the middle first, then the exec
excuse me what method can make it automatic display position in the play?
  •  Tags:  
  • Qt
  • Related