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. 1 Error + need an advice from you guys
Forum Updated to NodeBB v4.3 + New Features

1 Error + need an advice from you guys

Scheduled Pinned Locked Moved General and Desktop
27 Posts 5 Posters 7.1k 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.
  • SGaistS Offline
    SGaistS Offline
    SGaist
    Lifetime Qt Champion
    wrote on last edited by
    #3

    Hi,

    You are trying to add a layout which is not a QWidget.

    What you must use is addLayout.

    The compiler is innocent, it only compiles code. The widget "layouting" is done by the layout manager (e.g. QVBoxLayout) at run time when the widgets are created, added to it and shown.

    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
    • P Offline
      P Offline
      Project try
      wrote on last edited by
      #4

      Thanks guys ,

      1 Reply Last reply
      0
      • P Offline
        P Offline
        Project try
        wrote on last edited by
        #5

        Hey guys , sorry about asking again , when I compile now I get 4 errors which is about linking , when I delete Q_OBJECT from the header of my class the problem goes away , but in the book it says when you use slots and signals you should include it , what do you guys think ?

        Errors:

        bq. finddialong.obj:-1: error: LNK2001: unresolved external symbol "public: virtual struct QMetaObject const * __cdecl Finddialong::metaObject(void)const " (?metaObject@Finddialong@@UEBAPEBUQMetaObject@@XZ)

        finddialong.obj:-1: error: LNK2001: unresolved external symbol "public: virtual void * __cdecl Finddialong::qt_metacast(char const *)" (?qt_metacast@Finddialong@@UEAAPEAXPEBD@Z)

        finddialong.obj:-1: error: LNK2001: unresolved external symbol "public: virtual int __cdecl Finddialong::qt_metacall(enum QMetaObject::Call,int,void * *)" (?qt_metacall@Finddialong@@UEAAHW4Call@QMetaObject@@HPEAPEAX@Z)

        finddialong.obj:-1: error: LNK2001: unresolved external symbol "public: static struct QMetaObject const Finddialong::staticMetaObject" (?staticMetaObject@Finddialong@@2UQMetaObject@@B)

        debug\untitled10.exe:-1: error: LNK1120: 4 unresolved externals

        1 Reply Last reply
        0
        • JKSHJ Offline
          JKSHJ Offline
          JKSH
          Moderators
          wrote on last edited by
          #6

          Hi,

          [quote]in the book it says when you use slots and signals you should include it[/quote]Yes, the book is correct.

          [quote]finddialong.obj:-1: error: LNK2001: unresolved external symbol “public: virtual struct QMetaObject const * __cdecl Finddialong::metaObject(void)const “ (?metaObject@Finddialong@@UEBAPEBUQMetaObject@@XZ)[/quote]To avoid this error, run qmake after you add "Q_OBJECT" to the header.

          Qt Doc Search for browsers: forum.qt.io/topic/35616/web-browser-extension-for-improved-doc-searches

          1 Reply Last reply
          0
          • Q Offline
            Q Offline
            qxoz
            wrote on last edited by
            #7

            @Project try, take a look to "qt5-book-code":https://github.com/mutse/qt5-book-code it could be useful for continue learning

            1 Reply Last reply
            0
            • P Offline
              P Offline
              Project try
              wrote on last edited by
              #8

              @qxoz thanks , I'll check them out.

              I'm sorry for posting late guys , I had to sleep + go to college :(

              anyways when I installed qt it came with it a command prompt , when I opened it and wrote qmake it says you can place any variable assigement in option will be parsed and there's some option like -o file

              i don't know what to do , I'm new to this , usually I just run the compiler and it just works.

              1 Reply Last reply
              0
              • P Offline
                P Offline
                Project try
                wrote on last edited by
                #9

                Hey guys , I've gone to folder that the project is in " from command line that came with qt " and used qmake but it justs doesn't show anything , when I tried to compile it from qt creator it gives me the same error ?

                maybe because I used qmake in the project ? theree's two folders when I create a new project , one is for the project files and the other is called build ....

                1 Reply Last reply
                0
                • P Offline
                  P Offline
                  Project try
                  wrote on last edited by
                  #10

                  I guess nothing worked :(

                  1- tried using qmake in the command line , didn't work
                  2- cleaned the project then ran qmake and build it and it did not work
                  3- used a new project and it did not work

                  it just gives the same error and it says nameoffile.obj not found " the same error "

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

                    Windows is not especially user/developer friendly on the command line.

                    Where did you call qmake ? Did you call nmake afterwards ?

                    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
                    • P Offline
                      P Offline
                      Project try
                      wrote on last edited by
                      #12

                      I called qmake in the command line , also in the project " when you right click " you'll find an option called " qmake " , what is nmake ? becaus when I tried it in the command line it says there's no such thing.

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

                        nmake is the command that will read the Makefiles generated by qmake and call the compiler/linker etc…

                        But I am just realizing… What version of Qt is installed ? VSXXXX or MinGW ? If the later, you need to call mingw32-make after qmake

                        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
                        • P Offline
                          P Offline
                          Project try
                          wrote on last edited by
                          #14

                          Sorry for posting late , I have the qt 5.2.1 ( msvc 2010 , 32bit) if this is what you're looking for .. the creator is 3.0.1

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

                            Are you sure you are using the correct command line ?

                            Before taking too much time with it, does Qt Creator work correctly when building a default created application ? (using file -> new project -> use all defaults -> build )

                            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
                            • P Offline
                              P Offline
                              Project try
                              wrote on last edited by
                              #16

                              Yes it works fine with the default building , it shows the main window just fine , as I said when I remove q_object the problem goes away , not sure why.

                              sorry for wasting your time with me :(

                              1 Reply Last reply
                              0
                              • P Offline
                                P Offline
                                Project try
                                wrote on last edited by
                                #17

                                Let me just post the code here so you can check ^^

                                the interface for the class:

                                @#ifndef FINDDIALONG_H
                                #define FINDDIALONG_H
                                #include<QDialog>

                                class QCheckBox;
                                class QLabel;
                                class QLineEdit;
                                class QPushButton;

                                class Finddialong : public QDialog
                                {
                                Q_OBJECT
                                public:
                                Finddialong(QWidget *parent=0);
                                signals:
                                void findNext(const QString &str,Qt::CaseSensitivity cs);
                                void findPrevious(const QString &str,Qt::CaseSensitivity cs);
                                private slots:
                                void findClicked();
                                void enablefindButton(const QString &text);
                                private:
                                QLabel *label;
                                QLineEdit *lineEdit;
                                QCheckBox *backwardCheckBox;
                                QCheckBox *caseCheckBox;
                                QPushButton *findButton;
                                QPushButton *closeButton;
                                };

                                #endif // FINDDIALONG_H
                                @

                                the implement for the class:

                                @#include<QtGui>
                                #include "finddialong.h"
                                #include<QHBoxLayout>
                                #include<QVBoxLayout>
                                #include<QPushButton>
                                #include<QLabel>
                                #include<QLineEdit>
                                #include<QCheckBox>

                                Finddialong::Finddialong(QWidget *parent) : QDialog(parent)
                                {
                                label=new QLabel(tr("Find &what:"));
                                lineEdit = new QLineEdit;
                                label->setBuddy(lineEdit);
                                caseCheckBox=new QCheckBox(tr("Match &case"));
                                backwardCheckBox=new QCheckBox(tr("Search &backward"));
                                findButton=new QPushButton(tr("&Find"));
                                findButton->autoDefault();
                                findButton->setEnabled(false);
                                closeButton = new QPushButton(tr("close"));
                                connect(lineEdit,SIGNAL(textChanged(const QString &)),this,SLOT(enableFindButton(const QString &)));
                                connect(findButton,SIGNAL(clicked()),this,SLOT(findClicked()));
                                connect(closeButton,SIGNAL(clicked()),this,SLOT(close()));
                                QHBoxLayout *topLeftLayout=new QHBoxLayout;
                                topLeftLayout->addWidget(label);
                                topLeftLayout->addWidget(lineEdit);
                                QVBoxLayout *LeftLayout=new QVBoxLayout;
                                LeftLayout->addLayout(topLeftLayout);
                                LeftLayout->addWidget(backwardCheckBox);
                                LeftLayout->addWidget(caseCheckBox);
                                QVBoxLayout *rightLayout=new QVBoxLayout;
                                rightLayout->addWidget(findButton);
                                rightLayout->addWidget(closeButton);
                                rightLayout->addStretch();
                                QHBoxLayout *mainLayout=new QHBoxLayout;
                                mainLayout->addLayout(LeftLayout);
                                mainLayout->addLayout(rightLayout);
                                setLayout(mainLayout);

                                }@

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

                                  Then, did you try to call qmake "Run qmake" from the "Build" menu of Qt Creator ?

                                  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
                                  • P Offline
                                    P Offline
                                    Project try
                                    wrote on last edited by
                                    #19

                                    Yes :( same problem

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

                                      Also with a "Rebuild All" ?

                                      @#include <QtGui> << bad habit only include what you use@

                                      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
                                      • P Offline
                                        P Offline
                                        Project try
                                        wrote on last edited by
                                        #21

                                        yes I rebuild it all , if you can try the class and see what happens pls :(

                                        also about the qtgui in the book it says include it , but what does it do ? it says it contains two files.

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

                                          You are missing the implementation of both your slots. Once you add that you should be able to compile it.

                                          It's called a "module include". It will include everything from the module. You don't want your compiler to go through all of that when building an application (it can be ok for a quick prototyping but that's all)

                                          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

                                          • Login

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