我正在尝试使用 Qt Creator 创建一个简单的子类QGLWidget
,我使用 Qt Creator 向导生成了 .h 和 .cpp 文件,该向导生成了以下代码:
视口.cpp
#include "viewport.h"
Viewport::Viewport(QObject *parent) :
QGLWidget(parent)
{
}
视口.h
#ifndef VIEWPORT_H
#define VIEWPORT_H
#include <QGLWidget>
class Viewport : public QGLWidget
{
Q_OBJECT
public:
explicit Viewport(QObject *parent = 0);
signals:
public slots:
};
#endif // VIEWPORT_H
我添加QT += opengl
到消除了大部分错误的 .pro 文件中,但留下了两个我不明白的地方:
/projects/tree_gen/qt_project/tree_gen-build-desktop-Qt_4_8_4_in_PATH__System__Debug/../tree_gen/viewport.cpp:4: error: invalid conversion from 'QObject*' to 'QWidget*'
/projects/tree_gen/qt_project/tree_gen-build-desktop-Qt_4_8_4_in_PATH__System__Debug/../tree_gen/viewport.cpp:4: error: initializing argument 1 of 'QGLWidget::QGLWidget(QWidget*, const QGLWidget*, Qt::WindowFlags)'
我没有改变任何东西,只是试图编译 Qt 给我的东西,有什么想法吗?