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] Problem with Q_OBJECT
Forum Updated to NodeBB v4.3 + New Features

[Solved] Problem with Q_OBJECT

Scheduled Pinned Locked Moved General and Desktop
11 Posts 4 Posters 7.8k 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.
  • K Offline
    K Offline
    kamilus
    wrote on last edited by
    #1

    I have such a class myLabel:

    header:
    @#ifndef MYLABEL_H
    #define MYLABEL_H
    #include <QLabel>
    #include <QObject>

    class myLabel : public QLabel
    {
    //Q_OBJECT - when i uncomment it coompilator show me: undefined reference to 'vtable for myLabel'

    public:
    myLabel();
    bool flag_grid;

    private:
    //bool flag_grid;
    bool flag_markers;

    protected:
    void paintEvent(QPaintEvent *e);
    };

    #endif // MYLABEL_H@

    source file:
    @#include "myLabel.h"
    #include <QPainterPath>
    #include <QPainter>
    #include <QLabel>
    #include <QPixmap>

    myLabel::myLabel()
    {

    }
    do
    void myLabel::paintEvent(QPaintEvent *e){

    }@

    I would like to have a slots in this class but without Q_OBJECT it's impossible what i should add to this code to make it run??

    1 Reply Last reply
    0
    • T Offline
      T Offline
      tdmatsu
      wrote on last edited by
      #2

      have you tried running qmake after adding Q_OBJECT?

      1 Reply Last reply
      0
      • K Offline
        K Offline
        kamilus
        wrote on last edited by
        #3

        when i add Q_OBJECT to my header the compilator show me:
        undefined reference to 'vtable for myLabel'
        collect2: ld returned 1 exit status

        1 Reply Last reply
        0
        • R Offline
          R Offline
          rokemoon
          wrote on last edited by
          #4

          You can solve the problem if delete the folder where Qt save object files, and then recompile your project.
          In my case the folder has name "projectName-build-desktop".

          1 Reply Last reply
          0
          • K Offline
            K Offline
            kamilus
            wrote on last edited by
            #5

            i think it helped, but it's a little bit strange. In a minute i will do a slot and check this, but now it is compiling without any errors. Thanks a lot

            1 Reply Last reply
            0
            • K Offline
              K Offline
              kamilus
              wrote on last edited by
              #6

              it's work, once again thank You

              1 Reply Last reply
              0
              • R Offline
                R Offline
                rokemoon
                wrote on last edited by
                #7

                You are welcome :-)

                1 Reply Last reply
                0
                • D Offline
                  D Offline
                  DenisKormalev
                  wrote on last edited by
                  #8

                  As it was suggested you don't need to delete something by hands. Rerunning qmake (not compiler) should help you.
                  And if problem is solved don't forget to mark it as [solved].

                  1 Reply Last reply
                  0
                  • K Offline
                    K Offline
                    kamilus
                    wrote on last edited by
                    #9

                    Hey Denis, i know it's stupid question but where i should click to mark this thread as solved?? I don't see such option...
                    [quote author="Denis Kormalev" date="1306694082"]As it was suggested you don't need to delete something by hands. Rerunning qmake (not compiler) should help you.
                    And if problem is solved don't forget to mark it as [solved].[/quote]

                    1 Reply Last reply
                    0
                    • D Offline
                      D Offline
                      DenisKormalev
                      wrote on last edited by
                      #10

                      Simply edit your first post and add [solved] to title (better add it to beginning not to end of title)

                      1 Reply Last reply
                      0
                      • R Offline
                        R Offline
                        rokemoon
                        wrote on last edited by
                        #11

                        @Denis Kormalev: Oh, run qmake again work. I'm deleting folder by hands, because think that if i recompile all it call qmake too.
                        @kamilus just edit your post and add to begin [solved]

                        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