#include "example.h"
#include "ui_example.h"
#include "hi.h" //include the header file
example
::example(QWidget *parent
) : ui(new Ui::example)
{
ui->setupUi(this);
// note that the declaration of pointer can be done only once
connect(ui->pushButton, SIGNAL(clicked()), this, SLOT(on_pushButton_clicked())); //connect... the signal with slot ...
}
example::~example()
{
delete ui;
}
void example::on_pushButton_clicked()
{
//use the other class to instantiate the QDialog or the QDialog derived class (with or without ui)
hi *gamatos = new hi(this); //this is valid if the class name is "hi"... replace that with your class name //you need to pass 'this' as parent so that you don't get a memory leak
gamatos->show(); //you show the dialog
}
void example
::changeEvent(QEvent *e
) {
switch (e->type()) {
ui->retranslateUi(this);
break;
default:
break;
}
}
#include "example.h"
#include "ui_example.h"
#include "hi.h" //include the header file
example::example(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::example)
{
ui->setupUi(this);
// note that the declaration of pointer can be done only once
connect(ui->pushButton, SIGNAL(clicked()), this, SLOT(on_pushButton_clicked())); //connect... the signal with slot ...
}
example::~example()
{
delete ui;
}
void example::on_pushButton_clicked()
{
//use the other class to instantiate the QDialog or the QDialog derived class (with or without ui)
hi *gamatos = new hi(this); //this is valid if the class name is "hi"... replace that with your class name //you need to pass 'this' as parent so that you don't get a memory leak
gamatos->show(); //you show the dialog
}
void example::changeEvent(QEvent *e)
{
QMainWindow::changeEvent(e);
switch (e->type()) {
case QEvent::LanguageChange:
ui->retranslateUi(this);
break;
default:
break;
}
}
To copy to clipboard, switch view to plain text mode
NOTE: the code changed a bit... i corrected in the previous post, but you already copied... you can't declare the pointer twice (you don't declare it in the constructor, only in the slot)
Bookmarks