我对 C++ 中的 qt 有疑问
头文件:
#ifndef TIMER_H
#define TIMER_H
#include <QWidget>
#include <QTimer>
#include <QtGui>
#include <QObject>
class Timer : public QWidget
{
Q_OBJECT
public:
Timer(QWidget * parent = 0);
void setTimer(QString title, QString description, QDate date);
public slots:
void showWarning() {QString show = tit;
QPushButton * thanks = new QPushButton(QObject::tr("Thank you for reminding me!"));
show.append("\n");
show.append(des);
QMessageBox popup;
popup.setText(show);
popup.setWindowTitle("Calendar : Reminder");
popup.setDefaultButton(thanks);
popup.exec();
}
private:
QString tit;
QString des;
};
#endif // TIMER_H
cpp文件:
#include "timer.h"
Timer::Timer(QWidget * parent)
: QWidget(parent)
{
}
void Timer::setTimer(QString title, QString description, QDate date)
{
QDateTime now = QDateTime::currentDateTime();
QDateTime timeoftheaction;
QTimer *timer=new QTimer;
tit = title;
des = description;
timeoftheaction.setDate(date);
timeoftheaction.setTime(reminderTime);
QObject::connect(timer, SIGNAL(timeout()),this,SLOT(showWarning()));
timer->start(now.secsTo(timeoftheaction)*1000);
}
当我编译我得到错误:
........\QtSDK\Desktop\Qt\4.8.1\mingw\include/QtGui/qwidget.h:在复制构造函数'Timer::Timer(const Timer&)'中:..\projectOOI/timer。 h:9: 实例化自 'void QList::node_construct(QList::Node*, const T&) [with T =ointment]' ........\QtSDK\Desktop\Qt\4.8.1\mingw\ include/QtCore/qlist.h:512:
从 'void QList::append(const T&) [with T =ointment]' 实例化 ..\projectOOI/apppointoverview.h:10: 从这里实例化...... .\QtSDK\Desktop\Qt\4.8.1\mingw\include/QtGui/qwidget.h:806: 错误:'QWidget::QWidget(const QWidget&)' 是私有的 ..\projectOOI/timer.h:9: 错误: 在这种情况下
虽然我已经公开继承了 QWidget ......所以我不明白我哪里出错了