Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8637399
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T10:28:16+00:00 2026-06-12T10:28:16+00:00

I am building a small game in Qt4. here is the code: lcdcontrol.h :

  • 0

I am building a small game in Qt4. here is the code:

lcdcontrol.h :

#ifndef LCDCONTROL_H
#define LCDCONTROL_H



#include <QLCDNumber>
#include <QtGui>
#include <QWidget>

class lcdControl: public QWidget
{
    Q_OBJECT

public:
    lcdControl(QWidget *parent=0);

signals:
    void valueChanged(int newValue);

public slots:
    void setValue(int value);
    //void setRange(int minValue, int maxValue);
    //void quit();

private:
    QSlider *slider;
    //QPushButton *quitbutton;

};


#endif

lcdcontrol.cpp :

#include <QLCDNumber>
#include <QSlider>
#include <QGridLayout>

#include "lcdcontrol.h"

lcdControl::lcdControl(QWidget *parent): QWidget(parent)
{

    QLCDNumber *lcd = new QLCDNumber(2);                //2 for 2 digits
    lcd->setSegmentStyle(QLCDNumber::Filled);

    slider = new QSlider(Qt::Horizontal);
    slider->setRange(0,99);
    slider->setValue(0);

    connect(slider,SIGNAL(valueChanged(int)),lcd,SLOT(display(int)));   
    connect(slider,SIGNAL(valueChanged(int)),this,SIGNAL(valueChanged(int)));   

    QVBoxLayout *layout = new QVBoxLayout;
    layout->addWidget(lcd);
    layout->addWidget(slider);
    setLayout(layout);

    setFocusProxy(slider);
}

void lcdControl::setValue(int value)
{
    slider->setValue(value);
}

drawing.h :

#ifndef DRAWING_H
#define DRAWING_H

#include <QPushButton>

class drawingClass : public QWidget
{
    Q_OBJECT
public:
    drawingClass(QWidget *parent=0);

private:
    QPushButton *quitbutton;
};


#endif

drawing.cpp :

#include <QVBoxLayout>
#include <QGridLayout>
#include <QtGui>
#include "drawing.h"
#include "lcdcontrol.h"

drawingClass::drawingClass(QWidget *parent): QWidget(parent)
{

    quitbutton = new QPushButton(tr("&Quit!"));
    connect(quitbutton,SIGNAL(clicked()),qApp,SLOT(quit()));

    lcdControl *angle = new lcdControl;
    lcdControl *force = new lcdControl;

    QVBoxLayout *leftlayout = new QVBoxLayout;
    leftlayout->addWidget(angle);
    leftlayout->addWidget(force);

    QGridLayout *mainlayout = new QGridLayout;
    mainlayout->addWidget(quitbutton,0,0);
    mainlayout->addLayout(leftlayout);
    mainlayout->setColumnStrech(1,10);
    setLayout(mainlayout);
}

main.cpp

#include <QApplication>
#include <QtGui>
#include "drawing.h"

int main(int argc, char **argv)
{
    QApplication app(argc,argv);
    drawingClass ob;
    ob.resize(500,200);
    ob.show();
    return app.exec();
}

The error is:

main.cpp:(.text.startup+0x28): undefined reference to `drawingClass::drawingClass(QWidget*)'
main.cpp:(.text.startup+0x6e): undefined reference to `vtable for drawingClass'
main.cpp:(.text.startup+0x77): undefined reference to `vtable for drawingClass'
main.cpp:(.text.startup+0xb4): undefined reference to `vtable for drawingClass'
main.cpp:(.text.startup+0xbd): undefined reference to `vtable for drawingClass'
collect2: ld returned 1 exit status

Please help me out with this.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T10:28:17+00:00Added an answer on June 12, 2026 at 10:28 am

    YOu have not provided the linker with a definition of the drawingClass constructor.

    Most probably you forgot to add that .cpp file to the project.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm building a small game. On my document class i create a instances of
I'm building a small game - rock paper scissors. I have a prototype -
Im building a small space shooter game. I have how ever stubbed on a
I am building a small Recipe Organiser MVC project with EntityFramework Code first and
I am building a small web based game, using html 5. I need my
I'm building a small video game. I'm trying to do good oop/design. I have
I am building a small Space Invaders type game. Or at least trying to.
I am building a small game for iOS on Flash CS6 and I want
I'm building small web shop with asp.net mvc and Structuremap ioc/di. My Basket class
I´m building a small application with Jquery and PHP. Jquery (index.html) adds Form Fields

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.