Morea
23rd February 2006, 18:27
I have a strange problem. I made a simple app with a button, and connected the buttons clicked() to hide() of the mainwindow. When clicking this button the app crashed in windows 2000. I'm using Qt 4.
The program works fine in Linux. Strange. Is this a known bug or something else important that I have missed?
This is main.cpp
#include <QApplication>
#include "mainwindow.h"
int main(int argc, char *argv[])
{ QApplication app(argc, argv);
MainWindow *MainForm = new MainWindow;
MainForm->show();
return app.exec();
}
This is mainwindow.h
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
#include <QMainWindow>
#include "ui_mainwindow.h"
class MainWindow : public QMainWindow
{
Q_OBJECT
public:
MainWindow(QWidget * parent = 0);
private:
Ui::MainWindow ui;
};
#endif
this is mainwindow.cpp
#include <QtGui>
#include "mainwindow.h"
MainWindow::MainWindow(QWidget *parent)
: QMainWindow(parent, 0)
{ ui.setupUi(this);
}
this is the ui file
<ui version="4.0" >
<author></author>
<comment></comment>
<exportmacro></exportmacro>
<class>MainWindow</class>
<widget class="QMainWindow" name="MainWindow" >
<property name="geometry" >
<rect>
<x>0</x>
<y>0</y>
<width>425</width>
<height>248</height>
</rect>
</property>
<property name="windowTitle" >
<string>Test QT DevCPP</string>
</property>
<widget class="QWidget" name="centralWidget" >
<widget class="QPushButton" name="pushButton" >
<property name="geometry" >
<rect>
<x>40</x>
<y>80</y>
<width>75</width>
<height>24</height>
</rect>
</property>
<property name="text" >
<string>PushButton</string>
</property>
</widget>
</widget>
</widget>
<pixmapfunction></pixmapfunction>
<resources/>
<connections>
<connection>
<sender>pushButton</sender>
<signal>clicked()</signal>
<receiver>MainWindow</receiver>
<slot>hide()</slot>
<hints>
<hint type="sourcelabel" >
<x>81</x>
<y>114</y>
</hint>
<hint type="destinationlabel" >
<x>216</x>
<y>146</y>
</hint>
</hints>
</connection>
</connections>
</ui>
I can't see anything strange with this, can you?
The program works fine in Linux. Strange. Is this a known bug or something else important that I have missed?
This is main.cpp
#include <QApplication>
#include "mainwindow.h"
int main(int argc, char *argv[])
{ QApplication app(argc, argv);
MainWindow *MainForm = new MainWindow;
MainForm->show();
return app.exec();
}
This is mainwindow.h
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
#include <QMainWindow>
#include "ui_mainwindow.h"
class MainWindow : public QMainWindow
{
Q_OBJECT
public:
MainWindow(QWidget * parent = 0);
private:
Ui::MainWindow ui;
};
#endif
this is mainwindow.cpp
#include <QtGui>
#include "mainwindow.h"
MainWindow::MainWindow(QWidget *parent)
: QMainWindow(parent, 0)
{ ui.setupUi(this);
}
this is the ui file
<ui version="4.0" >
<author></author>
<comment></comment>
<exportmacro></exportmacro>
<class>MainWindow</class>
<widget class="QMainWindow" name="MainWindow" >
<property name="geometry" >
<rect>
<x>0</x>
<y>0</y>
<width>425</width>
<height>248</height>
</rect>
</property>
<property name="windowTitle" >
<string>Test QT DevCPP</string>
</property>
<widget class="QWidget" name="centralWidget" >
<widget class="QPushButton" name="pushButton" >
<property name="geometry" >
<rect>
<x>40</x>
<y>80</y>
<width>75</width>
<height>24</height>
</rect>
</property>
<property name="text" >
<string>PushButton</string>
</property>
</widget>
</widget>
</widget>
<pixmapfunction></pixmapfunction>
<resources/>
<connections>
<connection>
<sender>pushButton</sender>
<signal>clicked()</signal>
<receiver>MainWindow</receiver>
<slot>hide()</slot>
<hints>
<hint type="sourcelabel" >
<x>81</x>
<y>114</y>
</hint>
<hint type="destinationlabel" >
<x>216</x>
<y>146</y>
</hint>
</hints>
</connection>
</connections>
</ui>
I can't see anything strange with this, can you?