Using UI class from Designer?
Hello
I have finished a qt tutorial from another site. Everything runs fine except the GUI i made in QT Designer does not show up. All tutorials I can find on the subject implements it the same way.
So to summon it up. I only get a blank window when I run my project.
Main.cpp
Code:
#include <QtCore/QCoreApplication>
#include "TempForm.h"
#include "Window.h"
int main(int argc, char *argv[])
{
Window mWindow;
mWindow.resize(800,600);
mWindow.show();
return a.exec();
}
#endif
Window.h
Code:
#ifndef WINDOW_H
#define WINDOW_H
#include <QtOpenGl/QGLWidget>
#include <QtGui>
#include "TempForm.h"
class Window
: public QWidget ,
private Ui
::MainWindow //MainWindow is the class name from QT Designer header file (TempForm.h){
public:
~Window();
};
#endif
Window.cpp
Code:
#include <QtGui/QMouseEvent>
#include "Window.h"
{
}
Window::~Window()
{
}
If I manually call each guielemts show function my application crash.
Any suggestions?
Re: Using UI class from Designer?
Try this:
Code:
#include <QtGui/QMouseEvent>
#include "Window.h"
{
setupUi(this); // this sets up GUI
}
LE: And you include TempForm.h and private inherit from Ui::MainWindow? something is not right in there (you should public inherit the class that UIC created for you)
Here is the official guide that is presenting you all you need to know on how to integrate ui file in your c++ code.
Re: Using UI class from Designer?
Thanks for looking over it.
Yeah private inherit was not intended but dident solw the problem either.
Using this was giving an error witch is not strange. Thats why I was casting.
Code:
setupUi(this); // this sets up GUI
By inherit from QMainWindow rather than QWidget fixed the problem for me.
Re: Using UI class from Designer?
Quote:
Originally Posted by
miivers
I have finished a qt tutorial from another site. Everything runs fine except the GUI i made in QT Designer does not show up. All tutorials I can find on the subject implements it the same way.
Maybe you shouldn't take tutorials from those "other sites" ;)