开发者

How to add a Viewer from libQGLViewer, without using a .ui file

I've been writing my user interface directly instead of using the Qt UI design option, and I'm having trouble adding a Viewer panel.

I've copied the interface.h and interface.cpp files from this example code: http://www.libqglviewer.com/examples/interface.html, into my project, and attempted to insert a Viewer panel via the following code:

QGroupBox *groupBox;
groupBox = new QGroupBox();

QVBoxLayout *mainLayout = new QVBo开发者_运维问答xLayout;

Viewer viewer = new Viewer(groupBox);
textEdit = new QTextEdit;

mainLayout->addWidget(viewer);
mainLayout->addWidget(textEdit);

groupBox->setLayout(mainLayout);
setCentralWidget(groupBox);

but when I try to build, I get: error: C2664: 'QBoxLayout::addWidget' : cannot convert parameter 1 from 'Viewer' to 'QWidget *'

From what I can see in the ui code, the exact same command is used, and I can't see where the difference is: vboxLayout->addWidget(viewer);, and the type isn't converted anywhere else.

Any ideas? Many thanks.


This line is very suspicious:

Viewer viewer = new Viewer(groupBox);

Try with:

Viewer *viewer = new Viewer(groupBox);
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜