错误:课堂没有名为“ Show”的成员
error: class has no member named ‘show’
.h
#include <QtQuick/QQuickPaintedItem>
#include <QColor>
#include <QLineF>
#include <QMutex>
class MyGraph : public QQuickPaintedItem
{
Q_OBJECT
protected:
virtual void componentComplete();
public:
MyGraph (QQuickPaintedItem *parent = 0);
void paint (QPainter *painter);
};
.cpp
#include <QApplication>
#include <iostream>
#include <QPen>
#include "qpainter.h"
#include <QtQml/qqmlengine.h>
#include "graph.h"
MyGraph :: MyGraph (QQuickPaintedItem *parent) : QQuickPaintedItem (parent) {}
void MyGraph :: paint (QPainter *painter)
{
}
void MyGraph::componentComplete ()
{
QQuickPaintedItem::componentComplete ();
}
int main(int argc, char **argv)
{
QApplication app (argc, argv);
MyGraph g;
g.resize(200, 200);
g.show()
return app.exec();
}
错误:
:~/myQtGraph$ make
g++ -c -pipe -O2 -Wall -W -D_REENTRANT -fPIE -DQT_NO_DEBUG -DQT_QUICK_LIB -DQT_QML_LIB -DQT_WIDGETS_LIB -DQT_NETWORK_LIB -DQT_GUI_LIB -DQT_CORE_LIB -I/opt/Qt5.1.0/5.1.0/gcc_64/mkspecs/linux-g++ -I. -I. -I/opt/Qt5.1.0/5.1.0/gcc_64/include -I/opt/Qt5.1.0/5.1.0/gcc_64/include/QtQuick -I/opt/Qt5.1.0/5.1.0/gcc_64/include/QtQml -I/opt/Qt5.1.0/5.1.0/gcc_64/include/QtWidgets -I/opt/Qt5.1.0/5.1.0/gcc_64/include/QtNetwork -I/opt/Qt5.1.0/5.1.0/gcc_64/include/QtGui -I/opt/Qt5.1.0/5.1.0/gcc_64/include/QtCore -I. -o graph.o graph.cpp
graph.cpp:11:6: warning: unused parameter ‘painter’ [-Wunused-parameter]
graph.cpp: In function ‘int main(int, char**)’:
graph.cpp:26:5: error: ‘class MyGraph’ has no member named ‘resize’
graph.cpp:27:5: error: ‘class MyGraph’ has no member named ‘show’
make: *** [graph.o] Error 1
不确定为什么要搜索resize
和show
,因为它们不是QQuickPaintedItem
如果您有兴趣调整大小,请在下面使用代码。使用QSize
定义大小并使用setContentsSize
将其设置。
MyGraph g;
QSize size;
size.setHeight(200);
size.setWidth(200);
g.setContentsSize(size);
另外,您可以使用resetHeight()
和resetWidth()
相关文章:
- 将成员变量添加到共享库中的类中,不会破坏二进制兼容性吗
- 对RValue对象调用的LValue ref限定成员函数
- 为什么使用 "this" 指针调用派生成员函数?
- 具有奇怪重复模板模式的派生类中的成员变量已损坏
- 助记符和指向成员语法的指针
- 用于访问容器<T>数据成员的正确 API
- 内置函数可查看CPP中的成员变量
- 是否可以初始化不可复制类型的成员变量(或基类)
- 如果C++类在类方法中具有动态分配,但没有构造函数/析构函数或任何非静态成员,那么它仍然是POD类型吗
- 找不到成员对象:没有名为get_event()的成员,也处理多态性和向量
- 嵌套在类中时无法设置成员数据
- 为什么在没有显式默认构造函数的情况下,将另一个结构封装在联合中作为成员的结构不能编译
- 将函数类成员映射到类本身内部
- 基于另一个成员参数将函数调用从类传递给它的一个成员
- 将Ref对象作为类成员
- 将包含C样式数组的对象初始化为成员变量(C++)
- 静态数据成员的问题-修复链接错误会导致编译器错误
- 将公共但非静态的成员函数与ALGLIB集成
- 多成员Constexpr结构初始化
- 错误:课堂没有名为“ Show”的成员