hi everybody, thx for all replies..
I hope i am in the right way
Please let me now if i am in the right way or not, AND WHY I CANT SEE A Messagebox after clicking my okButton ;(
my steps:
1. Design my MainWindow
2. i have created a main.cpp:
#include "ui_mainwindow.h"
#include <QApplication>
int main(int argc, char *argv[])
{
Ui::MainWindow ui;
ui.setupUi(window);
window->show();
return app.exec();
}
#include "ui_mainwindow.h"
#include <QApplication>
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
QDialog *window = new QDialog;
Ui::MainWindow ui;
ui.setupUi(window);
window->show();
return app.exec();
}
To copy to clipboard, switch view to plain text mode
3. I have created a test.h:
#include "ui_mainwindow.h"
{
Q_OBJECT
public:
public slots:
void myfirstfunction();
private:
Ui::MainWindow ui;
};
#include "ui_mainwindow.h"
class MainWindow : public QDialog
{
Q_OBJECT
public:
MainWindow(QWidget *parent = 0);
public slots:
void myfirstfunction();
private:
Ui::MainWindow ui;
};
To copy to clipboard, switch view to plain text mode
4. I have created a test.cpp:
#include "test.h"
#include <QMessageBox>
MainWindow
::MainWindow(QWidget *parent
) {
ui.setupUi(this);
connect(ui.okButton, SIGNAL(clicked()), this, SLOT(myfirstfunction()));
connect(ui.cancelButton, SIGNAL(clicked()), this, SLOT(reject()));
}
void MainWindow::myfirstfunction()
{
"Unable to find the user preferences file.\n"
"The factory default will be used instead.");
}
#include "test.h"
#include <QMessageBox>
MainWindow::MainWindow(QWidget *parent)
: QDialog(parent)
{
ui.setupUi(this);
connect(ui.okButton, SIGNAL(clicked()), this, SLOT(myfirstfunction()));
connect(ui.cancelButton, SIGNAL(clicked()), this, SLOT(reject()));
}
void MainWindow::myfirstfunction()
{
QMessageBox::information(this, "Application name",
"Unable to find the user preferences file.\n"
"The factory default will be used instead.");
}
To copy to clipboard, switch view to plain text mode
5. qmake -project
.pro file:
######################################################################
# Automatically generated by qmake (2.00a) Sa 25. Feb 22:31:12 2006
######################################################################
TEMPLATE = app
TARGET +=
DEPENDPATH += .
INCLUDEPATH += .
# Input
HEADERS += test.h
FORMS += mainwindow.ui
SOURCES += main.cpp test.cpp
######################################################################
# Automatically generated by qmake (2.00a) Sa 25. Feb 22:31:12 2006
######################################################################
TEMPLATE = app
TARGET +=
DEPENDPATH += .
INCLUDEPATH += .
# Input
HEADERS += test.h
FORMS += mainwindow.ui
SOURCES += main.cpp test.cpp
To copy to clipboard, switch view to plain text mode
6. qmake
7. make I get a exe file without error
By clicking my okButton i cant see my Messagebox by calling myfirstfunction().
Bookmarks