制作自定义QProgressBar

时间:2016-07-29 10:38:31

标签: c++ qt 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

什么可能导致问题?

1 个答案:

答案 0 :(得分:1)

也许没有为你的标题运行moc(元对象编译器)? 无论如何,它是this question

的副本