问题
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!
回答1:
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.
Insert a dummy
QWidget
into the layout.Right click on the widget, select "Promote to...".
Add
PictureGLWidget
as a new class promoted fromQWidget
. Specify appropriate header files etc.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.
回答2:
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... ?
来源:https://stackoverflow.com/questions/31558297/is-is-possible-to-edit-an-individual-widget-in-the-qtdesginer