C++ (Qt)#include "main_form.h" #include <QtGui>#include <QApplication> int main(int argc, char *argv[]){ QApplication a(argc, argv); QTextCodec *codec=QTextCodec::codecForName("CP1251"); QTextCodec::setCodecForCStrings(codec); main_form *w=new main_form(0); w->show(); return a.exec();}
C++ (Qt)#include "main_form.h" main_form::main_form(QWidget *parent) : QMainWindow(parent){ ui.setupUi(this); this->setWindowTitle("Главная"); setAttribute(Qt::WA_DeleteOnClose); connect(ui.pushButton,SIGNAL(clicked()),this,SLOT(sl()));} main_form::~main_form(){ //QMessageBox::information(0,"деструктор","для main_form");}void main_form::sl(){ t=new doch(this); t->show();}
C++ (Qt)#ifndef MAIN_FORM_H#define MAIN_FORM_H #include <QtGui/QMainWindow>#include "ui_main_form.h"#include "doch.h" class doch;class main_form : public QMainWindow{ Q_OBJECT public: main_form(QWidget *parent = 0); ~main_form(); doch *t; private: Ui::main_formClass ui;private slots: void sl();}; #endif // MAIN_FORM_H
C++ (Qt)#include "doch.h" doch::doch(QWidget *parent) : QMainWindow(parent){ ui.setupUi(this); this->setWindowTitle("дочерняя");} doch::~doch(){ //QMessageBox::about(0,"деструктор","для two");}
C++ (Qt)#ifndef DOCH_H#define DOCH_H #include <QtGui/QMainWindow>#include <QMessageBox>#include <QCloseEvent>#include "ui_doch.h" class doch : public QMainWindow{ Q_OBJECT public: doch(QWidget *parent = 0); ~doch(); private: Ui::DochClass ui;}; #endif
C++ (Qt)int main(int argc, char *argv[]){ QApplication a(argc, argv); QTextCodec *codec=QTextCodec::codecForName("CP1251"); QTextCodec::setCodecForCStrings(codec); main_form w; w.show(); return a.exec();}