Hi Folks!
Hopefully someone can help me with this newbie problem...
I am fairly new to Qt, and I have been using MiniGW, QDevelop, Qt Designer and Qt 4.3 under WindowsXP to try and build a "Playground" applciation that I can add things to while I learn Qt. I haven't really used Qt before, but I have used various C++ API's, most notibly the BeAPI from BeOS and Haiku. I also haven't programmed for a few years, so I am a little unsure if my problem is not knowing how to use Qt, or me forgetting how to program C++ period
I expect my application to show a QMainWindow that will stay on the screen until I press the [x] button, at this point it will close. What I am getting is a Window that flashes on the screen and closes straight away, leaving a process in the Windows process list (I think this is because I am not deleting my new in the relevent destructor)
I have 3 source files, 3 header files and a .UI file. The .UI file contains a Window with a QMainWIndow object called PlaygroundWindowGUI. If needed, I can send a zip file of my folder to anyone that would like to help.
Playground.h:
#ifndef __MAIN_H__
#define __MAIN_H__
// place your code here
#endif // __MAIN_H__
Playground.cpp:
#include <stdio.h>
#include "Playground.h"
#include "PlaygroundApplication.h"
int main(int argc, char *argv[])
{// Main
printf ("Entering main...\n");
PlaygroundApplication Playground(argc, argv);
return Playground.exec();
}// Main
PlaygroundApplication.h:
#ifndef __PLAYGROUNDAPPLICATION_H__
#define __PLAYGROUNDAPPLICATION_H__
#include <QApplication>
class PlaygroundApplication : public QApplication
{
public:
PlaygroundApplication(int argc, char *argv[]);
};
#endif // __PLAYGROUNDAPPLICATION_H__
PlaygroundApplication.cpp:
#include "PlaygroundApplication.h"
#include "PlaygroundWindow.h"
PlaygroundApplication::PlaygroundApplication(int argc, char *argv[]):QApplication(argc, argv)
{
PlaygroundWindow thisPlaygroundWindow;
thisPlaygroundWindow.connect( &thisPlaygroundWindow, SIGNAL( lastWindowClosed() ), &thisPlaygroundWindow, SLOT( quit() ) );
thisPlaygroundWindow.show();
}
PlaygroundWindow.h:
#ifndef __PLAYGROUNDWINDOW_H__
#define __PLAYGROUNDWINDOW_H__
#include "ui_playgroundwindowgui.h"
class PlaygroundWindow : public QMainWindow, public Ui::PlaygroundWindowGUI
{
Q_OBJECT
public:
PlaygroundWindow( QWidget * parent = 0, Qt::WFlags f = 0 );
private slots:
};
#endif // __PLAYGROUNDWINDOW_H__
PlaygroundWindow.cpp:
#include "PlaygroundWindow.h"
PlaygroundWindow::PlaygroundWindow( QWidget * parent, Qt::WFlags f)
: QMainWindow(parent, f)
{
setupUi(this);
}
Can someone please help me work out why this isn't displaying like I expect?
Thanks,
Andrew McCall.
Bookmarks