PDA

View Full Version : qwidget.h: No such file or directory - issues dont stop...



larsemann
16th January 2011, 19:42
Hi,

i spent the whole day to just run a small application, and i got problem after problem.

i just started to install qt with the help of http://doc.qt.nokia.com/4.7/install-mac.html
- works for me.

but now, i havent got any idea, why i get the following error message



In file included from /main.cpp:21:
/usr/local/include/vtk-5.6/QVTKWidget.h:39:21: error: qwidget.h: No such file or directory


What the f.. is wrong with my libraries?
I got only problems with qt and the qvtk extension... ://

Just need help...

ChrisW67
16th January 2011, 23:53
It looks like your compiler does not know where to find Qt include files (not libraries). Can you build a simple Qt-only example?

main.cpp is:


#include <QApplication>
#include <QMainWindow>

int main(int argc, char *argv[])
{
QApplication app(argc, argv);

QMainWindow m;
m.show();
return app.exec();
}

and


$ qmake -project
$ qmake
$ make

larsemann
17th January 2011, 05:01
Hi,

yeah, that works well, i already tried it with the help of the qtcreator.
i think i have to study more on cmake-functionalities and how to write an adequate CMakelist.txt, before trying to get really good results with this amazing framework.

thanks for your help! ill keep on working ... ;)

ChrisW67
17th January 2011, 05:44
Mentioning that you were using CMake in your original question would probably have been useful :)

There is Qt4 support in CMake.
Compiling Qt4 apps with CMake could be useful.

larsemann
18th January 2011, 22:12
thank you for your help, i will definitely walk-through this help...

I'm just trying to find an own way through all of these compile-possibilities.

I'd just got a working version of an app, displaying a small vtk rendered stack of pictures. now my next task is to extend it with some functionalities from qt, f.e. a slider to slide through these pictures...
but for me its very difficult to get started with importing my cmake-prepared application into qtcreator to design the interface... and then connecting the interface with the app. puuah...

is there a good and easy way to extend a single main.cpp with an ordinary 'mainwindow.h' ( subclass of QMainWindow ), which has this QVTKWidget as CentralWidget? :D ;)

ChrisW67
19th January 2011, 01:01
You mean something like this:


#include <QtApplication>
#include <QMainWindow>
#include <QVTKWidget.h> // or whatever you need to include for this

int main(int argc, char *argv[])
{
QApplication app(argc,argv);

QMainWindow mainWindow;

QVTKWidget *widget = new QVTKWidget(&mainWindow);
mainWindow.setCentralWidget(widget);

mainWindow.show();
return app.exec();
}

larsemann
19th January 2011, 01:20
Yeah, but more like this:



#include <QtApplication>
#include "mainwindow.h" // own mainwindow subclass of QMainWindow with designed interface
#include <QVTKWidget.h> // or whatever you need to include for this

int main(int argc, char *argv[])
{
QApplication app(argc,argv);

MainWindow mainWindow;

QVTKWidget *widget = new QVTKWidget(&mainWindow);
mainWindow.setCentralWidget(widget);

mainWindow.show();
return app.exec();
}


But i always get a "symbol(s) not found" and "collector2 Id" error message, if i tryout... I guess those are standard include error messages from c++ compiler, but i don't know yet why. i think i'll have to work on it.

ChrisW67
19th January 2011, 02:54
What are the actual error messages. Don't paraphrase: copy and paste. My guess is that your build system is not adding the necessary libraries/library paths to the linking command i.e. "symbol(s) not found". I have no idea where "collector2 Id" is coming from but I would guess that collector2 is the name of something in your code.

You would normally insert the central widget of your QMainWindow in its constructor, not main.

larsemann
19th January 2011, 08:19
I haven't copied and pasted. I just hat this solution several times in different variations ;)

compiler output is:

_main in main.cpp.o
"MainWindow::MainWindow(QWidget*)", referenced from:
_main in main.cpp.o
ld: symbol(s) not found
collect2: ld returned 1 exit status


mainwindow.cpp

#include "mainwindow.h"
#include "ui_mainwindow.h"

#include <QVTKWidget>

MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
QVTKWidget *central = new QVTKWidget();
setCentralWidget(central);
}

MainWindow::~MainWindow()
{
delete ui;
}



main.cpp like in the last posting


MainWindow * main = new MainWindow();
main->show();

larsemann
19th January 2011, 13:44
Nice, solved it after re-reading http://www.vtk.org/Wiki/VTK/Tutorials/CMakeListsFileForQt4 .
Thank you, i'll be back ;)

msotaquira
15th February 2011, 07:29
Hi larsemann,

I've been following your posts since recently I've had the same issues (even when compiling VTK I had to adjust the flags for -fobjc)...

Anyway, up to this point I've just been able to compile Qt+VTK projects (the examples) using CMake, but for now I've not been able of doing this using QtCreator... Have you managed to do this or do you already make this using CMake...

For sure I would like to do everything (coding, compiling and executing the application) from the same place (that is from QtCreator)


Nice, solved it after re-reading http://www.vtk.org/Wiki/VTK/Tutorials/CMakeListsFileForQt4 .
Thank you, i'll be back ;)