[solved] New to Qt my test wont run
-
I have loaded an example from a book
C== GUI Programming with QT4 second editionput it in qt-5.3\Examples as spreadsheet
click on spreadsheet.pro to run it and build run.
it says a file cell.h is not found but it is there in that directory
What am I doing wrong
-
pro file is
@
TEMPLATE = app
HEADERS = cell.h
finddialog.h
gotocelldialog.h
mainwindow.h
sortdialog.h
spreadsheet.h
SOURCES = cell.cpp
finddialog.cpp
gotocelldialog.cpp
main.cpp
mainwindow.cpp
sortdialog.cpp
spreadsheet.cpp
FORMS = gotocelldialog.ui
sortdialog.ui
RESOURCES = spreadsheet.qrc
@
cell.h file is
@
#ifndef CELL_H
#define CELL_H#include <QTableWidgetItem>
class Cell : public QTableWidgetItem
{
public:
Cell();QTableWidgetItem *clone() const; void setData(int role, const QVariant &value); QVariant data(int role) const; void setFormula(const QString &formula); QString formula() const; void setDirty();
private:
QVariant value() const;
QVariant eval[removed]const QString &str, int &pos) const;
QVariant evalTerm(const QString &str, int &pos) const;
QVariant evalFactor(const QString &str, int &pos) const;mutable QVariant cachedValue; mutable bool cacheIsDirty;
};
#endif
@line in error is
@
#include <QTableWidgetItem>
@
I think[edit: Added missing coding tags @ SGaist]
-
Hi and welcome to devnet,
Since you are using a Qt 4 example with Qt 5 you are missing QT += widgets in your pro file.
-
is there an easy way to convert Qt4 code to Qt5
as your answer allowed me to pass the previous error and now have pages of problems
or is ther a list of things that changed ?
I would have thought Qt5 would have added features but not rendered Qt4 code inoperable.
-
Search in the documentation for "C++ API changes"
The biggest "visible" change in Qt 5 is the widgets module. The port from Qt 4 to Qt 5 is generally simple.
What errors are you getting ?
-
21:17:08: Running steps for project spreadsheet...
21:17:08: Configuration unchanged, skipping qmake step.
21:17:08: Starting: "C:\Qt\Tools\mingw482_32\bin\mingw32-make.exe"
C:/Qt/Tools/mingw482_32/bin/mingw32-make -f Makefile.Debug
mingw32-make[1]: Entering directory 'D:/QAHN/OPERA/Qt-4/qt-book-examples/qt-book/chap04/build-spreadsheet-Desktop_Qt_5_3_MinGW_32bit-Debug'
g++ -c -pipe -fno-keep-inline-dllexport -g -frtti -Wall -Wextra -fexceptions -mthreads -DUNICODE -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_CORE_LIB -DQT_NEEDS_QMAIN -I..\spreadsheet -I"C:\Qt\5.3\mingw482_32\include" -I"C:\Qt\5.3\mingw482_32\include\QtWidgets" -I"C:\Qt\5.3\mingw482_32\include\QtGui" -I"C:\Qt\5.3\mingw482_32\include\QtCore" -I"debug" -I"." -I"." -I"C:\Qt\5.3\mingw482_32\mkspecs\win32-g++" -o debug\finddialog.o ..\spreadsheet\finddialog.cpp
..\spreadsheet\finddialog.cpp: In constructor 'FindDialog::FindDialog(QWidget*)':
..\spreadsheet\finddialog.cpp:8:41: error: invalid use of incomplete type 'class QLabel'
label = new QLabel(tr("Find &what:"));
^
In file included from ..\spreadsheet\finddialog.cpp:3:0:
..\spreadsheet\finddialog.h:7:7: error: forward declaration of 'class QLabel'
class QLabel;
^
..\spreadsheet\finddialog.cpp:9:20: error: invalid use of incomplete type 'class QLineEdit'
lineEdit = new QLineEdit;
^
In file included from ..\spreadsheet\finddialog.cpp:3:0:
..\spreadsheet\finddialog.h:8:7: error: forward declaration of 'class QLineEdit'
class QLineEdit;
^
..\spreadsheet\finddialog.cpp:10:10: error: invalid use of incomplete type 'class QLabel'
label->setBuddy(lineEdit);
^
In file included from ..\spreadsheet\finddialog.cpp:3:0:
..\spreadsheet\finddialog.h:7:7: error: forward declaration of 'class QLabel'
class QLabel;
^
..\spreadsheet\finddialog.cpp:12:51: error: invalid use of incomplete type 'class QCheckBox'
caseCheckBox = new QCheckBox(tr("Match &case"));
^
In file included from ..\spreadsheet\finddialog.cpp:3:0:
..\spreadsheet\finddialog.h:6:7: error: forward declaration of 'class QCheckBox'
class QCheckBox;
^
..\spreadsheet\finddialog.cpp:13:60: error: invalid use of incomplete type 'class QCheckBox'
backwardCheckBox = new QCheckBox(tr("Search &backward"));
^
In file included from ..\spreadsheet\finddialog.cpp:3:0:
..\spreadsheet\finddialog.h:6:7: error: forward declaration of 'class QCheckBox'
class QCheckBox;
^
..\spreadsheet\finddialog.cpp:15:45: error: invalid use of incomplete type 'class QPushButton'
findButton = new QPushButton(tr("&Find"));
^
In file included from C:\Qt\5.3\mingw482_32\include\QtWidgets/QDialog:1:0,
from ..\spreadsheet\finddialog.h:4,
from ..\spreadsheet\finddialog.cpp:3:
C:\Qt\5.3\mingw482_32\include\QtWidgets/qdialog.h:50:7: error: forward declaration of 'class QPushButton'
class QPushButton;
^
..\spreadsheet\finddialog.cpp:16:15: error: invalid use of incomplete type 'class QPushButton'
findButton->setDefault(true);
^
In file included from C:\Qt\5.3\mingw482_32\include\QtWidgets/QDialog:1:0,
from ..\spreadsheet\finddialog.h:4,
from ..\spreadsheet\finddialog.cpp:3:
C:\Qt\5.3\mingw482_32\include\QtWidgets/qdialog.h:50:7: error: forward declaration of 'class QPushButton'
class QPushButton;
^
..\spreadsheet\finddialog.cpp:17:15: error: invalid use of incomplete type 'class QPushButton'
findButton->setEnabled(false);
^
In file included from C:\Qt\5.3\mingw482_32\include\QtWidgets/QDialog:1:0,
from ..\spreadsheet\finddialog.h:4,
from ..\spreadsheet\finddialog.cpp:3:
C:\Qt\5.3\mingw482_32\include\QtWidgets/qdialog.h:50:7: error: forward declaration of 'class QPushButton'
class QPushButton;
^
..\spreadsheet\finddialog.cpp:19:46: error: invalid use of incomplete type 'class QPushButton'
closeButton = new QPushButton(tr("Close"));
^
In file included from C:\Qt\5.3\mingw482_32\include\QtWidgets/QDialog:1:0,
from ..\spreadsheet\finddialog.h:4,
from ..\spreadsheet\finddialog.cpp:3:
C:\Qt\5.3\mingw482_32\include\QtWidgets/qdialog.h:50:7: error: forward declaration of 'class QPushButton'
class QPushButton;
^
..\spreadsheet\finddialog.cpp:22:58: error: no matching function for call to 'FindDialog::connect(QLineEdit*&, const char*, FindDialog* const, const char*)'
this, SLOT(enableFindButton(const QString &)));
^
..\spreadsheet\finddialog.cpp:22:58: note: candidates are:
In file included from C:\Qt\5.3\mingw482_32\include/QtCore/qabstractanimation.h:45:0,
from C:\Qt\5.3\mingw482_32\include/QtCore/QtCore:4,
from C:\Qt\5.3\mingw482_32\include/QtGui/QtGuiDepends:2,
from C:\Qt\5.3\mingw482_32\include\QtGui/QtGui:3,
from ..\spreadsheet\finddialog.cpp:1: -
Do you have somewhere a
@#include <QtGui>@
If so add
@#include <QtWidgets>@
These are module includes and should only be used for rapid prototyping or simple examples.
Otherwise always only include classes that you are currently using.
-
Follow this fine "wiki entry":http://qt-project.org/wiki/Deploy_an_Application_on_Windows for deployment.
Or if you really only want an exe then you will have to compile Qt statically first (there's some licensing concerns with that)
-
lets not run before I can walk.
Yes all I want is an exe to run my Qt program directly without using Qt-creator
something that goes direct to a run of the program. (on my computer) or perhaps also on my laptop.
my test program is now running and started to modify it, so all is going well
-
So your current problem is solved :)
Then please update the thread title prepending [solved] so other forum users may know a solution has been found :)