C++ 在Qt creator中升级QWidget,构造函数出现问题

C++ 在Qt creator中升级QWidget,构造函数出现问题,c++,qt,qt-creator,qwidget,C++,Qt,Qt Creator,Qwidget,I子类QGraphicsView: class CustomGraphicsView : public QGraphicsView { public: CustomGraphicsView(QWidget *parent = 0); ... } .cpp文件中的构造函数的实现方式如下: CustomGraphicsView::CustomGraphicsView(QWidget * parent): QGraphicsView(parent) { } 现在我通过Qt crea

I子类
QGraphicsView

class CustomGraphicsView : public QGraphicsView
{
public:
    CustomGraphicsView(QWidget *parent = 0);
...
}
.cpp文件中的构造函数的实现方式如下:

CustomGraphicsView::CustomGraphicsView(QWidget * parent):
    QGraphicsView(parent)
{
}
现在我通过Qt creator将QGraphicsView小部件升级到CustomGraphicsView。但是当我想连接到ImageWindow类的构造函数中提升的小部件时

ImageWindow::ImageWindow(QWidget *parent) :
    QDialog(parent),
    ui(new Ui::ImageWindow)
{
    ui->setupUi(this);

    CustomGraphicsView * view = ui->graphicsView();

}
我收到错误消息:

term does not evaluate to a function taking 0 arguments.
我为构造函数指定了一个默认值,即QWidget*parent=0,并且在
ui\u image\u窗口中设置了一个参数:

graphicsView = new CustomGraphicsView(ImageWindow);

那么是什么导致了这个错误呢?

这是因为
graphicsView
是一个成员而不是一个方法,所以不需要括号。只需像
view=ui->graphicsView
那样访问它。这对于生成的UI类中的所有Qt小部件都是一样的——它们只是成员,而不是方法。

F****CK!那花了我很多时间。我认为这是一个返回指针的方法:(谢谢!