mywidget.h#include <QWidget>class QPushButton;class MyWidget : public QWidget{ Q_OBJECT public: MyWidget(QWidget *parent = 0); private: QPushButton *reloadButton; QPushButton *exitButton;};----------------------------------------------------------------------------mywdiget.cpp#include <QApplication>#include <QtGui>#include "mywidget.h" MyWidget::MyWidget(QWidget *parent) : QWidget(parent) { reloadButton = new QPushButton(tr("Reload"),this); exitButton = new QPushButton(tr("Exit"),this); QVBoxLayout *buttonLayout = new QVBoxLayout(this); buttonLayout->addWidget(reloadButton); buttonLayout->addWidget(exitButton); setLayout(buttonLayout); connect(exitButton, SIGNAL(clicked()), this, SLOT(close())); }int main (int argc, char **argv){ QApplication app(argc,argv); MyWidget win; QTranslator translator; translator.load("test.qm"); app.installTranslator(&translator); win.show(); return app.exec();};--------------------------------------------------
int main (int argc, char **argv) { QApplication app(argc,argv); QTranslator translator; translator.load("test.qm"); app.installTranslator(&translator); MyWidget win; win.show(); return app.exec(); };