0

I got a external library, which includes a derived class from QGLWidget, very similar to that one here. In that library I have a class:

class PictureGLWidget : public QGLWidget { //.. }

This extends Qt's native QGLWidget and personalizes it. But it was not written by me, I just got it, via a *.dll. So then, I bind that Widget manually in my code to a layout like:

QGridLayout* layout = new QGridLayout;
layout->addWidget(myPictureGLWidget, 0, 1);
ui->verticalLayout_5->addLayout(layout);

since I designed my MainWindowWidget with the integrated QtDesigner, which is by the way very comfortable, I would like to handle my myPictureGLWidget also in the QtDesigner, since I am currently redesigning the MainWindow.

Is there a way doing that? Thnx in advance!

4

2 回答 2

0

I might have misunderstood your question but don't you just add a QGLWidget to your design in Designer. Right click the widget and select Promote to... ?

于 2015-07-22T10:28:01.903 回答
0

Qt Designer supports any foreign widget class without needing to provide plugins for that. You only have to accept that the widget's properties and appearance won't be available within Designer.

  1. Insert a dummy QWidget into the layout.

  2. Right click on the widget, select "Promote to...".

  3. Add PictureGLWidget as a new class promoted from QWidget. Specify appropriate header files etc.

  4. Promote your widget to PictureGLWidget.

When this is done, the code generated by uic will instantiate a PictureGLWidget where you need it, instead of a dummy QWidget.

If you want to use the PictureGLWidget in the designer instead of a dummy widget, you can write a designer plugin that wraps the widget and exposes it in the widget pallette, provides property support, etc.

于 2015-07-22T21:34:49.600 回答