ich habe ein 08/15 Program und bei klicken auf den OK Button moechte ich eine QMessageBox bekommen. Ich sehe dass die Methode des klickens ausgefuehrt wird. Aber, die QMessageBox wird nicht angezeigt und das Program wird sofort beendet (sprich es koennte auch sein, dass die QMessageBox fuer einen Bruchteil einer Sekunde angezeigt wird). Hat jemand eine Idee?
Und hier das Coding:
testapp.cpp
Code: Alles auswählen
#include "testapp.h"
#include <iostream>
#include <QtGui>
#include <QtCore>
using namespace std;
TestApp::TestApp(QDialog *parent) : QDialog(parent)
{
setupUi(this);
connect(okButton, SIGNAL (clicked()), this, SLOT(slotClose()));
}
TestApp::~TestApp()
{}
void TestApp::slotClose()
{
cout << "Diesen Text sehe ich auf der Konsole";
QMessageBox::information( this, "Titel", "Text", QMessageBox::Ok);
}
Code: Alles auswählen
#ifndef TESTAPP_H
#define TESTAPP_H
#include "ui_testapp.h"
#include <QtGui>
#include <QtCore>
class TestApp : public QDialog, public Ui::TestApp{
Q_OBJECT
public:
TestApp (QDialog *parent = 0);
~TestApp();
private slots:
void slotClose();
};
#endif //TESTAPP_H
Code: Alles auswählen
#include <QtCore>
#include <QtGui>
#include "testapp.h"
int main( int argc, char* argv[]){
QApplication a(argc, argv);
TestApp w;
w.show();
QObject::connect(&a, SIGNAL(lastWindowClosed()),&a, SLOT(quit()));
return a.exec();
}
J.