,, can you tell me the value in two QDialog switch languages, such as the main window to run, click Settings window, select English, how to make the main window in the QLabel also show English? Specific two QDialog subclass, the following code:
The class parentDialog: public QDialog
{
Q_OBJECT
Public:
ParentDialog (QWidget * parent=nullptr);//Settings window borderless
~ parentDialog ();
Protected:
The QPoint m_curPoint;
Void paintEvent (QPaintEvent * event);
Void mousePressEvent (QMouseEvent * event);
Void mouseMoveEvent (QMouseEvent * event);
Bool eventfilters (QObject * watched, QEvent * event);
};
The class mainDialog: public parentDialog
{
Q_OBJECT
Public:
MainDialog (QWidget * parent=nullptr);//Settings window borderless
~ mainDialog ();
Void initUi ();
Private:
QPushButton * m_closeBtn;
QPushButton * m_settingsBtn;
QLabel * m_labelTip;
Private slots:
Void slotShowSettingsDlg ();
}
The class SettingsDialog: public QDialog
{
Q_OBJECT
Public:
SettingsDialog (QWidget * parent=nullptr);//Settings window borderless
~ SettingsDialog ();
Void initUi ();
Private:
QPushButton * m_closeBtn;
QComboBox * m_comBox;
QLabel * m_label;
QPushButton * m_okBtn;
Private slots:
Void slotClickedBtnOkFun ();
}
//
Void mainDialog: : initUi ()
{
M_closeBtn=new QPushButton (this);
M_closeBtn - & gt; SetFocusPolicy (Qt: : NoFocus);//not focus as the default
M_closeBtn - & gt; SetToolTip (" close ");
M_closeBtn - & gt; InstallEventFilter (this);
QImage closeImg (" :/res/PWD/Closebtn PNG ");
M_closeBtn - & gt; The resize (closeImg. The size ());
M_closeBtn - & gt; Move (this - & gt; Width () * 99/100 - closeImg. Width (), and this - & gt; Height () * 1/100);
The connect (m_btnClose, & amp; QPushButton: : clicked, this, & amp; MainDialog: : reject);
M_settingsBtn=new QPushButton (this);
M_settingsBtn - & gt; SetFocusPolicy (Qt: : NoFocus);
M_settingsBtn - & gt; SetToolTip (" set ");
M_settingsBtn - & gt; InstallEventFilter (this);
QImage settingsImg (" :/res/main/SettingBtn PNG ");
M_settingsBtn - & gt; The resize (settingsImg. The size ());
M_settingsBtn - & gt; Move (this - & gt; Width () * 99/100 - closeImg. Width () - settingsImg. Width (), and this - & gt; Height () * 1/100);
The connect (m_btnSettings, & amp; QPushButton: : clicked, this, & amp; MainDialog: : slotShowSettingsDlg);
M_labelTip=new QLabel (" hello, this);
M_labelTip - & gt; SetAlignment (Qt: : AlignLeft);
M_labelTip - & gt; The resize (this - & gt; Width () * 60/100, this - & gt; Height () * 20/100);
M_labelTip - & gt; Move (this - & gt; Width () * 16/100, this - & gt; Height () * 6/100);
}
Void mainDialog: : slotShowSettingsDlg ()
{
SettingsDialog setsDlg;
Int res=setsDlg. The exec ();
If (res!=QDialog: : Accepted)
{
return;
}
}
Void SettingsDialog: : initUi ()
{
M_closeBtn=new QPushButton (this);
M_closeBtn - & gt; SetFocusPolicy (Qt: : NoFocus);//not focus as the default
M_closeBtn - & gt; SetToolTip (" close ");
M_closeBtn - & gt; InstallEventFilter (this);
QImage closeImg (" :/res/PWD/Closebtn PNG ");
M_closeBtn - & gt; The resize (closeImg. The size ());
M_closeBtn - & gt; Move (this - & gt; Width () * 99/100 - closeImg. Width (), and this - & gt; Height () * 1/100);
The connect (m_btnClose, & amp; QPushButton: : clicked, this, & amp; SettingsDialog: : reject);
M_comBox=new QComboBox (this);
M_comBox - & gt; AddItem (" Chinese ");
M_comBox - & gt; AddItem (" English ");
QImage langImg (" :/res/sets/comboBoxBkg PNG ");
M_comBox - & gt; The resize (langImg. The size ());
M_comBox - & gt; Move (this - & gt; Width () * 60/100, this - & gt; Height () * 50/100);
M_okBtn=new QPushButton (" sure ", this);
M_btnOk - & gt; SetFocusPolicy (Qt: : NoFocus);
M_btnOk - & gt; InstallEventFilter (this);
QImage okImg (" :/res/sets/btnOk0 PNG ");
M_btnOk - & gt; The resize (okImg. The size ());
M_btnOk - & gt; Move (this - & gt; Width () * 51/100, this - & gt; Height () * 76/100);
The connect (m_btnOk, & amp; QPushButton: : clicked, this, & amp; SettingsDlg: : slotClickedBtnOkFun);
}
Void SettingsDialog: : slotClickedBtnOkFun ()
{
After//above, choose English, how to so as to deliver information to the main window mainDialog m_labelTip text information into English?
}
Also, every brother please give directions, the younger brother in this thank you very much!