PDA

View Full Version : error:invalid use of undefined type 'struct QWorkspace'



LiCodeX
21st September 2007, 13:49
hi,

idk if somebody has tried this before, but I had first time opportunity to use Qworkspace API in my program and the compiler is throwing out this puzzling error each time::
error:invalid use of undefined type 'struct QWorkspace'

I've included the required QWorkspace header file properly in my header file, but still I'm getting this error, code snippets are as follows:
Header file snippet is::


#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include <QMainWindow>

class QWorkspace;

class MainWindow : public QMainWindow
{
Q_OBJECT
public:
MainWindow();
private:
QWorkspace *workspace;

};
#endif


CPP file snippet is ::


#include <QtGui>

#include "test.h"

MainWindow::MainWindow()
{
workspace = new QWorkspace;
setCentralWidget(workspace);

/*some stupid code of application*/

}

is there anything I'm missing out in that?



Thanks

jpn
21st September 2007, 17:05
Are you sure this is exactly the same code you were compiling? It's just that I can't see anything syntactically wrong and the includes sure are sufficient...

momesana
22nd September 2007, 00:16
The following code which is infact the above classes put in a single file compiles and executes just fine on my system.



#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include <QMainWindow>

class QWorkspace;

class MainWindow : public QMainWindow
{
Q_OBJECT
public:
MainWindow();
private:
QWorkspace *workspace;

};
#endif


#include <QtGui>

MainWindow::MainWindow()
{
workspace = new QWorkspace;
setCentralWidget(workspace);

/*some stupid code of application*/

}

int main(int argc, char **argv)
{
QApplication app(argc, argv);
MainWindow mw;
mw.show();
return app.exec();
}

#include "main.moc"

LiCodeX
28th September 2007, 08:53
Thanks jpn and momesana for your quick and helpful replies.
Actually it worked out later on, i don't know what was the problem initially when I was compiling it, but it got compiled well, after giving it second shot.
I guess may be there was linking libraries problem with the Makefile I created on my own >:<

Thanks and Regards

jpn
28th September 2007, 09:26
I guess may be there was linking libraries problem with the Makefile I created on my own
Wow, does somebody still write makefiles by hand these days. Why not use qmake which would do it for you? :)

LiCodeX
28th September 2007, 10:23
Wow, does somebody still write makefiles by hand these days. Why not use qmake which would do it for you? :)

:o yeah it was unnecessary futile attempt to get it done on my own.
sometimes getting word done by easy utility bothers me a bit :p


Thanks