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]Microsoft Visual Studio 2010 compiler
Forum Updated to NodeBB v4.3 + New Features

[SOLVED]Microsoft Visual Studio 2010 compiler

Scheduled Pinned Locked Moved General and Desktop
12 Posts 3 Posters 9.6k 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.
  • M Offline
    M Offline
    Mr.FreakyJo
    wrote on last edited by
    #1

    After i introduce the Q_OBJECT macro in a class I get the folowing error:
    @mainwindow.obj : error LNK2019: unresolved external symbol "public: __thiscall dialogPlanNewAtack::dialogPlanNewAtack(void)" (??0dialogPlanNewAtack@@QAE@XZ) referenced in function "public: __thiscall mainWindow::mainWindow(void)" (??0mainWindow@@QAE@XZ)
    1>moc_mainwindow.obj : error LNK2019: unresolved external symbol "private: void __thiscall mainWindow::planNewAtack(void)" (?planNewAtack@mainWindow@@AAEXXZ) referenced in function "private: static void __cdecl mainWindow::qt_static_metacall(class QObject *,enum QMetaObject::Call,int,void * *)" (?qt_static_metacall@mainWindow@@CAXPAVQObject@@W4Call@QMetaObject@@HPAPAX@Z)
    1>debug\mainWindow.exe : fatal error LNK1120: 2 unresolved externals@

    I tried fixing this by running qmake on the files but it didn't worked.I have no other ideea on how to fix this.Please help me.

    This is how the declaration of the class looks:
    @#ifndef MAINWINDOW_H
    #define MAINWINDOW_H
    #include "ui_mainWindow.h"
    #include <QMainWindow>
    class mainWindow: public QMainWindow,Ui::MainWindow
    {
    Q_OBJECT
    public:
    mainWindow();
    private slots:
    void planNewAtack();
    };
    #endif@

    1 Reply Last reply
    0
    • S Offline
      S Offline
      shahid.pk
      wrote on last edited by
      #2

      There could be too reasons for the above error

      1. moc is not executed for the mainwindow class to generate c++ code for the compiler.

      2.If moc is executed which qmake do by default then implementation of mainwindow and the declaration of mainwindow will be in the same file

      make sure you are not doing the above two things...

      Love to learn....

      1 Reply Last reply
      0
      • M Offline
        M Offline
        Mr.FreakyJo
        wrote on last edited by
        #3

        the declaration is in mainwindow.h and the implementantion is in mainwindow.cpp and moc_mainwindow.cpp .

        @if !defined(Q_MOC_OUTPUT_REVISION)
        #error "The header file 'mainwindow.h' doesn't include <QObject>."
        #elif Q_MOC_OUTPUT_REVISION != 63
        #error "This file was generated using the moc from 4.8.0. It"
        #error "cannot be used with the include files from this version of Qt."
        #error "(The moc has changed too much.)"@

        This is the file generated by moc

        1 Reply Last reply
        0
        • ? This user is from outside of this forum
          ? This user is from outside of this forum
          Guest
          wrote on last edited by
          #4

          MOC shouldn't have problems as long as you followed best practices and declared everything in separate headers with all files included in the project file.

          What exactly are you trying to achieve by inheriting Ui::MainWindow?

          1 Reply Last reply
          0
          • G Offline
            G Offline
            goetz
            wrote on last edited by
            #5

            Method planNewAtack() is not implemented.

            http://www.catb.org/~esr/faqs/smart-questions.html

            1 Reply Last reply
            0
            • ? This user is from outside of this forum
              ? This user is from outside of this forum
              Guest
              wrote on last edited by
              #6

              Ah yes, I recently stumbled upon this issue in Creator/GCC as well, this is NOT MSVC compiler specific at all. Even an empty temporary implementation did the trick

              1 Reply Last reply
              0
              • M Offline
                M Offline
                Mr.FreakyJo
                wrote on last edited by
                #7

                Thanks Volker.I forgot that I create the dialog in main constructor and forgot to delete that slot.

                1 Reply Last reply
                0
                • M Offline
                  M Offline
                  Mr.FreakyJo
                  wrote on last edited by
                  #8

                  Now i have another error,hope you read this.Why I receive the error 'class' type redefinition?I changed the class name and I still receive this error.The header of the class is something like this:
                  @#ifndef DIALOGPLANNEWATACK_H
                  #define DIALOGPLANNEWATAC_H
                  #include <QDialog>
                  #include "ui_dialogPlanNewAtack.h"
                  class dialogPlanAtacktest :public QDialog,Ui::dialogPlanNewAtack
                  {
                  int i;
                  public:
                  dialogPlanAtacktest();
                  };
                  #endif@

                  1 Reply Last reply
                  0
                  • G Offline
                    G Offline
                    goetz
                    wrote on last edited by
                    #9

                    It's impossible to say what's going wrong without seing the rest of the code.

                    http://www.catb.org/~esr/faqs/smart-questions.html

                    1 Reply Last reply
                    0
                    • M Offline
                      M Offline
                      Mr.FreakyJo
                      wrote on last edited by
                      #10

                      i missed a letter in de header guard :)

                      1 Reply Last reply
                      0
                      • ? This user is from outside of this forum
                        ? This user is from outside of this forum
                        Guest
                        wrote on last edited by
                        #11

                        Why don't you just let Creator do the header guards for you? Instead of creating a header and cpp file just create a new class and you got it all.

                        You can also use Creator to automatically create method implementations and even sync changes in them. Besides saving time this is a great way to avoid nasty little typos.

                        You can still use the MSVC compiler from Creator, it will be detected and you will be offered MSVC build configurations.

                        1 Reply Last reply
                        0
                        • M Offline
                          M Offline
                          Mr.FreakyJo
                          wrote on last edited by
                          #12

                          I'm not used with Creator...I'll try the Creator when I will have a deeper undestanding in QT and more experience in it.I learnt C++ and Qt on my own and still got a lot to learn.

                          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