Updated from buntu 11.0 to 12.04. I use to have QT4 ver 4.7.4, now I have 4.8.1.
My project is failing to build because it can't find #include <QWidget>. A search of the disk tells me there is no QWidget file. (It was there B/4 the update.)
Other online comments say QWidget has been deprecated. Others say it is still there, and supported. Some say it is supported as an add-on. I have libqt4-dev installed. I see nothing that mentions an QWidget add-on.
So right about now I don't know what is what. Can someone shed some light on this?

gcc -c viewer.cxx
In file included from viewer.cxx:2:0:  
viewer.h:5:45: fatal error: QWidget: No such file or directory
compilation terminated.

I get the same type of failure when I use <QtGui/GWidget>. I have found the file @ /user/include/qt4/QtGui/ (Why I didn't find it before, I'm not sure.) It appears I have an issue with the projects cmake.
Let me work on this for a bit. Thanks.

  • Welcome to Ask Ubuntu! The libqt4-dev package really contains this file in 12.04! I believe something else is causing the issue. Can you post the exact error message you get when you compile? Also provide the output of apt-cache policy libqt4-dev as well as find /usr -iname "QWidget.h" -type f (will take a while to complete). And what happens if you use #include <QtGui/QWidget> instead? Do this by editing your question. Thanks. – gertvdijk Jan 21 '13 at 21:00
  • "Other online comments say QWidget has been deprecated." They're telling lies. Maybe this is changed in 5.x of Qt, but it's definitely supported in the complete 4.x release. See also QtWidget class reference (4.8). I think your compiler just does not know where to find these Qt header files. Could you include a minimal code example (here or on paste.ubuntu.com for example)? I'll try to reproduce it here. Oh and CMake Lists file tutorial for Qt4 is here. – gertvdijk Jan 21 '13 at 21:40
  • I have it compiling now. It fails to link properly. undefined reference to QVTKWidget2::QVTKWidget(QWidget*, QGLWidget const*, QFlags<QT::WindowType>) How do I find out which lib QVTKWidget2 is in? i.e. Which lib is it not finding? – Dug Jan 21 '13 at 22:35
  • Good, but please post the solution to the QWidget issue as an answer to your own question. This latest comment is not Qt anymore I believe. You're trying to compile VTK stuff there... Please ask a new question! P.S. It may take some time before you can answer your own question while you're still on a lower reputation count. – gertvdijk Jan 21 '13 at 22:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.