制作自定义 QProgressBar
Making custom QProgressBar
我在尝试启动以下代码时遇到 undefined reference to vtable for CustomProgressBar'
错误:
customprogressbar.h
#ifndef CUSTOMPROGRESSBAR_H
#define CUSTOMPROGRESSBAR_H
#include <QProgressBar>
#include "task.h"
class CustomProgressBar : public QProgressBar
{
Q_OBJECT
public:
CustomProgressBar(DayTask, QWidget* parent = 0);
protected:
void paintEvent(QPaintEvent *) Q_DECL_OVERRIDE;
private:
DayTask task;
};
#endif // CUSTOMPROGRESSBAR_H
customprogressbar.cpp
#include "customprogressbar.h"
#include <QPainter>
CustomProgressBar::CustomProgressBar(DayTask task, QWidget* parent) :
task{task},
QProgressBar(parent)
{
}
//paintevent
什么可能导致问题?
也许 moc(元 object 编译器)没有被 运行 用于您的 header?
无论如何,this question
是重复的
我在尝试启动以下代码时遇到 undefined reference to vtable for CustomProgressBar'
错误:
customprogressbar.h
#ifndef CUSTOMPROGRESSBAR_H
#define CUSTOMPROGRESSBAR_H
#include <QProgressBar>
#include "task.h"
class CustomProgressBar : public QProgressBar
{
Q_OBJECT
public:
CustomProgressBar(DayTask, QWidget* parent = 0);
protected:
void paintEvent(QPaintEvent *) Q_DECL_OVERRIDE;
private:
DayTask task;
};
#endif // CUSTOMPROGRESSBAR_H
customprogressbar.cpp
#include "customprogressbar.h"
#include <QPainter>
CustomProgressBar::CustomProgressBar(DayTask task, QWidget* parent) :
task{task},
QProgressBar(parent)
{
}
//paintevent
什么可能导致问题?
也许 moc(元 object 编译器)没有被 运行 用于您的 header? 无论如何,this question
是重复的