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. Error: undefined reference to 'vtable for TimeGraphics'
Forum Updated to NodeBB v4.3 + New Features

Error: undefined reference to 'vtable for TimeGraphics'

Scheduled Pinned Locked Moved General and Desktop
3 Posts 2 Posters 703 Views 2 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
    houmingc
    wrote on last edited by houmingc
    #1

    Error: undefined reference to 'vtable for TimeGraphics'
    This class can handle signals and slots and it has a slot called timeWidget_ticker
    which is connected to a timer, which means once in a while this function would be called. This function will tick QLabel

    '''
    class TimeGraphics: public QObject, public QGraphicsRectItem{
    Q_OBJECT
    public:
    TimeGraphics();
    public slots:
    void timeWidget_ticker();
    private:
    QLabel* timeWidget;
    };

    '''
    TimeGraphics::TimeGraphics()
    {

    QLabel *timeWidget = new QLabel;
    timeWidget->setStyleSheet("QLabel {color:white;}");
    QTimer *systemTimer1 = new QTimer(this);
    connect(systemTimer1,SIGNAL(timeout()), this, SLOT(timeWidget_ticker));
    systemTimer1->start();
    

    }

    void TimeGraphics::timeWidget_ticker()
    {
    QTime time = QTime::currentTime();
    QString time_text = time.toString("hh : mm : ss");
    if (time.second() % 2 == 0)
    {
    time_text[3]= ' ';
    time_text[8]= ' ';
    }
    timeWidget->setText(time_text);
    }

    1 Reply Last reply
    0
    • H Offline
      H Offline
      houmingc
      wrote on last edited by
      #2

      It is solved after running qmake and clean.
      But i can't create object onto Graphics with the code below

      '''
      TimeGraphics *timerWidget = new TimeGraphics();
      scene.addItem(timerWidget);

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

        Hi,

        What do you mean by "can't create" ? What your expecting ? What 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

        • Login

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