Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. [solved] New to Qt my test wont run
Forum Updated to NodeBB v4.3 + New Features

[solved] New to Qt my test wont run

Scheduled Pinned Locked Moved General and Desktop
14 Posts 3 Posters 4.3k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • H Offline
    H Offline
    HopkDe
    wrote on last edited by
    #1

    I have loaded an example from a book
    C== GUI Programming with QT4 second edition

    put 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

    1 Reply Last reply
    0
    • D Offline
      D Offline
      dasun
      wrote on last edited by
      #2

      First of all you don't have to put your project file in to Examples directory.
      Can you please give us a like to your example project?

      1 Reply Last reply
      0
      • H Offline
        H Offline
        HopkDe
        wrote on last edited by
        #3

        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]

        1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          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.

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply
          0
          • H Offline
            H Offline
            HopkDe
            wrote on last edited by
            #5

            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.

            1 Reply Last reply
            0
            • SGaistS Offline
              SGaistS Offline
              SGaist
              Lifetime Qt Champion
              wrote on last edited by
              #6

              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 ?

              Interested in AI ? www.idiap.ch
              Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

              1 Reply Last reply
              0
              • H Offline
                H Offline
                HopkDe
                wrote on last edited by
                #7

                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:

                1 Reply Last reply
                0
                • SGaistS Offline
                  SGaistS Offline
                  SGaist
                  Lifetime Qt Champion
                  wrote on last edited by
                  #8

                  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.

                  Interested in AI ? www.idiap.ch
                  Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                  1 Reply Last reply
                  0
                  • H Offline
                    H Offline
                    HopkDe
                    wrote on last edited by
                    #9

                    That seems to have fixed it it now runs.

                    One more question how do I make anexecutable .exe file so as to just run the application ( on thsi or another computer)

                    Thanks for your help so far

                    1 Reply Last reply
                    0
                    • SGaistS Offline
                      SGaistS Offline
                      SGaist
                      Lifetime Qt Champion
                      wrote on last edited by
                      #10

                      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)

                      Interested in AI ? www.idiap.ch
                      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                      1 Reply Last reply
                      0
                      • H Offline
                        H Offline
                        HopkDe
                        wrote on last edited by
                        #11

                        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

                        1 Reply Last reply
                        0
                        • SGaistS Offline
                          SGaistS Offline
                          SGaist
                          Lifetime Qt Champion
                          wrote on last edited by
                          #12

                          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 :)

                          Interested in AI ? www.idiap.ch
                          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                          1 Reply Last reply
                          0
                          • H Offline
                            H Offline
                            HopkDe
                            wrote on last edited by
                            #13

                            OK but how do you do that I only see a place to post a reply

                            1 Reply Last reply
                            0
                            • H Offline
                              H Offline
                              HopkDe
                              wrote on last edited by
                              #14

                              OK done solved added

                              1 Reply Last reply
                              0

                              • Login

                              • Login or register to search.
                              • First post
                                Last post
                              0
                              • Categories
                              • Recent
                              • Tags
                              • Popular
                              • Users
                              • Groups
                              • Search
                              • Get Qt Extensions
                              • Unsolved