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. unresolved external symbol "public: static struct QMetaObject const staticMetaObject"
Forum Updated to NodeBB v4.3 + New Features

unresolved external symbol "public: static struct QMetaObject const staticMetaObject"

Scheduled Pinned Locked Moved Solved General and Desktop
qt6qmetaobjectmsvc2022
26 Posts 4 Posters 6.1k Views
  • 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.
  • Christian EhrlicherC Christian Ehrlicher

    @a_coder said in unresolved external symbol "public: static struct QMetaObject const staticMetaObject":

    which vaule i can use in signal and slots?

    How should I know which value you send through signals and slot. If you want which datatype then, as I already said, anything which consists of only one word to not confuse the moc compiler.

    A Offline
    A Offline
    a_coder
    wrote on last edited by a_coder
    #16

    @Christian-Ehrlicher i want to synchronized my countdown from two windows so i send the signal with the time remain in there.however, i don't think that will make the code error

    JonBJ 1 Reply Last reply
    0
    • A a_coder

      @Christian-Ehrlicher i want to synchronized my countdown from two windows so i send the signal with the time remain in there.however, i don't think that will make the code error

      JonBJ Online
      JonBJ Online
      JonB
      wrote on last edited by
      #17

      @a_coder
      @Christian-Ehrlicher has suggested you do not use a type written as e.g. long long as a signal parameter, as moc may not like it. I don't know, but I would try obeying his hint and change that to see if it helps.

      A 1 Reply Last reply
      0
      • JonBJ JonB

        @a_coder
        @Christian-Ehrlicher has suggested you do not use a type written as e.g. long long as a signal parameter, as moc may not like it. I don't know, but I would try obeying his hint and change that to see if it helps.

        A Offline
        A Offline
        a_coder
        wrote on last edited by
        #18

        @JonB now i removed long long in signal and it will get that in Timer class but i still got some errors

        Build started at 8:33 CH...
        1>------ Build started: Project: project, Configuration: Debug x64 ------
        1>Reading Qt configuration (E:/Qt/6.7.0/msvc2019_64/bin/qmake)
        1>uic mainw.ui
        1>uic workspace.ui
        1>moc control.h
        1>moc mainw.h
        1>moc workspace.h
        1>main.cpp
        1>mainw.cpp
        1>workspace.cpp
        1>moc_control.cpp
        1>moc_mainw.cpp
        1>G:\project\project\control.h(77,7): error C2143: syntax error: missing ';' before '*'
        1>(compiling source file 'x64/Debug/moc/moc_mainw.cpp')
        1>G:\project\project\control.h(77,7): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
        1>(compiling source file 'x64/Debug/moc/moc_mainw.cpp')
        1>G:\project\project\control.h(77,14): error C2238: unexpected token(s) preceding ';'
        1>(compiling source file 'x64/Debug/moc/moc_mainw.cpp')
        1>G:\project\project\control.h(51,15): error C2061: syntax error: identifier 'Mainw'
        1>(compiling source file 'x64/Debug/moc/moc_mainw.cpp')
        1>G:\project\project\control.h(51,27): error C2612: trailing ')' illegal in base/member initializer list
        1>(compiling source file 'x64/Debug/moc/moc_mainw.cpp')
        1>G:\project\project\mainw.h(12,2): warning C4081: expected ')'; found 'string'
        1>(compiling source file 'x64/Debug/moc/moc_mainw.cpp')
        1>G:\project\project\x64\Debug\moc\moc_mainw.cpp(32,1): warning C4081: expected ')'; found 'string'
        1>G:\project\project\x64\Debug\moc\moc_mainw.cpp(159,1): error C1004: unexpected end-of-file found
        1>Done building project "project.vcxproj" -- FAILED.
        ========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
        ========== Build completed at 8:33 CH and took 11,009 seconds ==========
        
        jsulmJ 1 Reply Last reply
        0
        • A a_coder

          @JonB now i removed long long in signal and it will get that in Timer class but i still got some errors

          Build started at 8:33 CH...
          1>------ Build started: Project: project, Configuration: Debug x64 ------
          1>Reading Qt configuration (E:/Qt/6.7.0/msvc2019_64/bin/qmake)
          1>uic mainw.ui
          1>uic workspace.ui
          1>moc control.h
          1>moc mainw.h
          1>moc workspace.h
          1>main.cpp
          1>mainw.cpp
          1>workspace.cpp
          1>moc_control.cpp
          1>moc_mainw.cpp
          1>G:\project\project\control.h(77,7): error C2143: syntax error: missing ';' before '*'
          1>(compiling source file 'x64/Debug/moc/moc_mainw.cpp')
          1>G:\project\project\control.h(77,7): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
          1>(compiling source file 'x64/Debug/moc/moc_mainw.cpp')
          1>G:\project\project\control.h(77,14): error C2238: unexpected token(s) preceding ';'
          1>(compiling source file 'x64/Debug/moc/moc_mainw.cpp')
          1>G:\project\project\control.h(51,15): error C2061: syntax error: identifier 'Mainw'
          1>(compiling source file 'x64/Debug/moc/moc_mainw.cpp')
          1>G:\project\project\control.h(51,27): error C2612: trailing ')' illegal in base/member initializer list
          1>(compiling source file 'x64/Debug/moc/moc_mainw.cpp')
          1>G:\project\project\mainw.h(12,2): warning C4081: expected ')'; found 'string'
          1>(compiling source file 'x64/Debug/moc/moc_mainw.cpp')
          1>G:\project\project\x64\Debug\moc\moc_mainw.cpp(32,1): warning C4081: expected ')'; found 'string'
          1>G:\project\project\x64\Debug\moc\moc_mainw.cpp(159,1): error C1004: unexpected end-of-file found
          1>Done building project "project.vcxproj" -- FAILED.
          ========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
          ========== Build completed at 8:33 CH and took 11,009 seconds ==========
          
          jsulmJ Offline
          jsulmJ Offline
          jsulm
          Lifetime Qt Champion
          wrote on last edited by
          #19

          @a_coder Please post current control.h and also mark the line 77 there

          https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply
          1
          • A Offline
            A Offline
            a_coder
            wrote on last edited by
            #20

            @jsulm

            #ifndef CONTROLER_H
            #define CONTROLER_H
            
            #include <qobject.h>
            #include <qtimer.h>
            #include <qobject.h>
            #include "mainw.h"
            #include "workspace.h"
            
            
            class Timer :public QObject {
            	Q_OBJECT
            public:
            	Timer(long long &timesetup, QObject* parent = nullptr)
            		:QObject(parent)
            		,counter(new QTimer)
            	{
            		timereaining = &timesetup;
            		connect(counter, &QTimer::timeout, this, &Timer::sendupdate);
            	}
            	long long timeleft() { return *timereaining; }
            	void start() {
            		counter->setInterval(1000);
            		counter->start();
            	}
            signals:
            	void requestupdated();
            	void timeout();
            private slots:
            	void sendupdate() {
            		if (*timereaining <= 0) {
            			emit timeout();
            		}
            		else {
            			(*timereaining)--;
            			emit requestupdated();
            		}
            	}
            private:
            	long long* timereaining;
            	QTimer* counter;
            };
            
            class control :public QObject {
            	Q_OBJECT
            public:
            	control(Timer* time, QObject* parent = nullptr):
            		QObject(parent)
            		,timer(time)
            		, workspace(new Workspace(timer))
            		, mainw(new Mainw(timer))
            	{
            		/*mainw = new Mainw(timer);
            		workspace = new Workspace(timer);*/
            	}
            	~control() {
            	}
            	void start() {
            		connect(mainw, &Mainw::change_gui, this, &control::changeto_workspace_slot);
            		connect(workspace, &Workspace::change_gui, this, &control::changeto_mainw_slot);
            		mainw->start();
            	}
            //signals:
            	//void changeto_mainw();
            	//void changeto_workspace();
            private slots:
            	void changeto_mainw_slot() {
            		mainw->start();
            		workspace->close();
            	}
            	void changeto_workspace_slot() {
            		workspace->start();
            		mainw->close();
            	}
            private:
            	Timer* timer;
            	Mainw* mainw; //line 77
            	Workspace* workspace;
            };
            #endif // CONTROLER_H 
            

            sorry idk how to mark that

            jsulmJ 2 Replies Last reply
            0
            • A a_coder

              @jsulm

              #ifndef CONTROLER_H
              #define CONTROLER_H
              
              #include <qobject.h>
              #include <qtimer.h>
              #include <qobject.h>
              #include "mainw.h"
              #include "workspace.h"
              
              
              class Timer :public QObject {
              	Q_OBJECT
              public:
              	Timer(long long &timesetup, QObject* parent = nullptr)
              		:QObject(parent)
              		,counter(new QTimer)
              	{
              		timereaining = &timesetup;
              		connect(counter, &QTimer::timeout, this, &Timer::sendupdate);
              	}
              	long long timeleft() { return *timereaining; }
              	void start() {
              		counter->setInterval(1000);
              		counter->start();
              	}
              signals:
              	void requestupdated();
              	void timeout();
              private slots:
              	void sendupdate() {
              		if (*timereaining <= 0) {
              			emit timeout();
              		}
              		else {
              			(*timereaining)--;
              			emit requestupdated();
              		}
              	}
              private:
              	long long* timereaining;
              	QTimer* counter;
              };
              
              class control :public QObject {
              	Q_OBJECT
              public:
              	control(Timer* time, QObject* parent = nullptr):
              		QObject(parent)
              		,timer(time)
              		, workspace(new Workspace(timer))
              		, mainw(new Mainw(timer))
              	{
              		/*mainw = new Mainw(timer);
              		workspace = new Workspace(timer);*/
              	}
              	~control() {
              	}
              	void start() {
              		connect(mainw, &Mainw::change_gui, this, &control::changeto_workspace_slot);
              		connect(workspace, &Workspace::change_gui, this, &control::changeto_mainw_slot);
              		mainw->start();
              	}
              //signals:
              	//void changeto_mainw();
              	//void changeto_workspace();
              private slots:
              	void changeto_mainw_slot() {
              		mainw->start();
              		workspace->close();
              	}
              	void changeto_workspace_slot() {
              		workspace->start();
              		mainw->close();
              	}
              private:
              	Timer* timer;
              	Mainw* mainw; //line 77
              	Workspace* workspace;
              };
              #endif // CONTROLER_H 
              

              sorry idk how to mark that

              jsulmJ Offline
              jsulmJ Offline
              jsulm
              Lifetime Qt Champion
              wrote on last edited by
              #21

              @a_coder Please also post mainw.h

              https://forum.qt.io/topic/113070/qt-code-of-conduct

              1 Reply Last reply
              1
              • A a_coder

                @jsulm

                #ifndef CONTROLER_H
                #define CONTROLER_H
                
                #include <qobject.h>
                #include <qtimer.h>
                #include <qobject.h>
                #include "mainw.h"
                #include "workspace.h"
                
                
                class Timer :public QObject {
                	Q_OBJECT
                public:
                	Timer(long long &timesetup, QObject* parent = nullptr)
                		:QObject(parent)
                		,counter(new QTimer)
                	{
                		timereaining = &timesetup;
                		connect(counter, &QTimer::timeout, this, &Timer::sendupdate);
                	}
                	long long timeleft() { return *timereaining; }
                	void start() {
                		counter->setInterval(1000);
                		counter->start();
                	}
                signals:
                	void requestupdated();
                	void timeout();
                private slots:
                	void sendupdate() {
                		if (*timereaining <= 0) {
                			emit timeout();
                		}
                		else {
                			(*timereaining)--;
                			emit requestupdated();
                		}
                	}
                private:
                	long long* timereaining;
                	QTimer* counter;
                };
                
                class control :public QObject {
                	Q_OBJECT
                public:
                	control(Timer* time, QObject* parent = nullptr):
                		QObject(parent)
                		,timer(time)
                		, workspace(new Workspace(timer))
                		, mainw(new Mainw(timer))
                	{
                		/*mainw = new Mainw(timer);
                		workspace = new Workspace(timer);*/
                	}
                	~control() {
                	}
                	void start() {
                		connect(mainw, &Mainw::change_gui, this, &control::changeto_workspace_slot);
                		connect(workspace, &Workspace::change_gui, this, &control::changeto_mainw_slot);
                		mainw->start();
                	}
                //signals:
                	//void changeto_mainw();
                	//void changeto_workspace();
                private slots:
                	void changeto_mainw_slot() {
                		mainw->start();
                		workspace->close();
                	}
                	void changeto_workspace_slot() {
                		workspace->start();
                		mainw->close();
                	}
                private:
                	Timer* timer;
                	Mainw* mainw; //line 77
                	Workspace* workspace;
                };
                #endif // CONTROLER_H 
                

                sorry idk how to mark that

                jsulmJ Offline
                jsulmJ Offline
                jsulm
                Lifetime Qt Champion
                wrote on last edited by
                #22

                @a_coder Btw. it is not a good idea to have more than one QObject based class in one header file - this can cause problems with moc tool.

                https://forum.qt.io/topic/113070/qt-code-of-conduct

                A JonBJ 2 Replies Last reply
                0
                • jsulmJ jsulm

                  @a_coder Btw. it is not a good idea to have more than one QObject based class in one header file - this can cause problems with moc tool.

                  A Offline
                  A Offline
                  a_coder
                  wrote on last edited by
                  #23

                  @jsulm i detached it before and these are my files
                  mainw.h

                  #ifndef MAINW_H
                  #define MAINW_H
                  
                  #include <qmainwindow.h>
                  #include "ui_mainw.h"
                  #include "control.h"
                  
                  class Timer;
                  class control;
                  
                  class Mainw : public QMainWindow {
                  	Q_OBJECT
                  public:
                  	void start();
                  	Mainw(Timer* time, QWidget* parent = nullptr);
                  	~Mainw();
                  signals:
                  	void change_gui();
                  private:
                  	Ui::Main* ui;
                  	Timer* timer;
                  private slots:
                  	void updatetime();
                  	void toworkspace() {
                  		ui->pushButton->setDisabled(true);
                  		emit change_gui();
                  		this->close();
                  	}
                  };
                  #endif // !MAINW_H
                  

                  workspace.h

                  #ifndef WORKSPACE_H
                  #define WORKSPACE_H
                  
                  #include <qprocess.h>
                  #include <qmainwindow.h>
                  #include "ui_workspace.h"
                  #include "control.h"
                  
                  class Timer;
                  
                  class Workspace : public QWidget {
                  	Q_OBJECT
                  public:
                  	Workspace(Timer* time, QWidget* parent = nullptr);
                  	~Workspace();
                  	void start();
                  signals:
                  	void change_gui();
                  private:
                  	//store all processes the ui run in a vector
                  	std::vector<QProcess*> processes;
                  	Ui::workspace* ui;
                  	Timer* timer;
                  private slots:
                  	void updatetime();
                  	void goback();
                  };
                  
                  #endif // WORKSPACE_H
                  
                  jsulmJ 1 Reply Last reply
                  0
                  • jsulmJ jsulm

                    @a_coder Btw. it is not a good idea to have more than one QObject based class in one header file - this can cause problems with moc tool.

                    JonBJ Online
                    JonBJ Online
                    JonB
                    wrote on last edited by JonB
                    #24

                    @jsulm said in unresolved external symbol "public: static struct QMetaObject const staticMetaObject":

                    more than one QObject based class in one header file

                    I don't want to derail this thread, but spoke to @Chris-Kawa a while ago and we both agree we have done this for years with no problems. Maybe we just don't do something "unusual/naughty/complicated".

                    1 Reply Last reply
                    0
                    • A a_coder

                      @jsulm i detached it before and these are my files
                      mainw.h

                      #ifndef MAINW_H
                      #define MAINW_H
                      
                      #include <qmainwindow.h>
                      #include "ui_mainw.h"
                      #include "control.h"
                      
                      class Timer;
                      class control;
                      
                      class Mainw : public QMainWindow {
                      	Q_OBJECT
                      public:
                      	void start();
                      	Mainw(Timer* time, QWidget* parent = nullptr);
                      	~Mainw();
                      signals:
                      	void change_gui();
                      private:
                      	Ui::Main* ui;
                      	Timer* timer;
                      private slots:
                      	void updatetime();
                      	void toworkspace() {
                      		ui->pushButton->setDisabled(true);
                      		emit change_gui();
                      		this->close();
                      	}
                      };
                      #endif // !MAINW_H
                      

                      workspace.h

                      #ifndef WORKSPACE_H
                      #define WORKSPACE_H
                      
                      #include <qprocess.h>
                      #include <qmainwindow.h>
                      #include "ui_workspace.h"
                      #include "control.h"
                      
                      class Timer;
                      
                      class Workspace : public QWidget {
                      	Q_OBJECT
                      public:
                      	Workspace(Timer* time, QWidget* parent = nullptr);
                      	~Workspace();
                      	void start();
                      signals:
                      	void change_gui();
                      private:
                      	//store all processes the ui run in a vector
                      	std::vector<QProcess*> processes;
                      	Ui::workspace* ui;
                      	Timer* timer;
                      private slots:
                      	void updatetime();
                      	void goback();
                      };
                      
                      #endif // WORKSPACE_H
                      
                      jsulmJ Offline
                      jsulmJ Offline
                      jsulm
                      Lifetime Qt Champion
                      wrote on last edited by jsulm
                      #25

                      @a_coder said in unresolved external symbol "public: static struct QMetaObject const staticMetaObject":

                      #include "control.h"

                      class Timer;
                      class control;

                      You have a circular dependency: mainw.h includes control.h and control.h includes mainw.h. This is not going to work. Since you only use Timer* in mainw.h and already have a forward declaration for it, the control.h include is not needed, remove it.

                      https://forum.qt.io/topic/113070/qt-code-of-conduct

                      A 1 Reply Last reply
                      0
                      • jsulmJ jsulm

                        @a_coder said in unresolved external symbol "public: static struct QMetaObject const staticMetaObject":

                        #include "control.h"

                        class Timer;
                        class control;

                        You have a circular dependency: mainw.h includes control.h and control.h includes mainw.h. This is not going to work. Since you only use Timer* in mainw.h and already have a forward declaration for it, the control.h include is not needed, remove it.

                        A Offline
                        A Offline
                        a_coder
                        wrote on last edited by
                        #26

                        @jsulm it worked, thanks

                        1 Reply Last reply
                        0
                        • A a_coder has marked this topic as solved on

                        • Login

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