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!

Community
  • 1
  • 1
Ralf Wickum
  • 2,850
  • 9
  • 55
  • 103
  • surely you used designer to create this widget you are adding – AngryDuck Jul 22 '15 at 10:18
  • @AngryDuck No, the Widget I am adding, was not written by me. I got it as a *.dll. – Ralf Wickum Jul 22 '15 at 12:55
  • a widget as a dll... i assume you mean you using a library that contains a widget which is what your are getting an instance of in your code then adding to your layout... if this is the case then i have no idea how you would get it into designer, i have done this with my own lib stuff but that needed compiling in VS2012 and then importing as a qt designer plugin i assume the lib your using wont have it compiled in a way that designer plugins will understand though :/ – AngryDuck Jul 22 '15 at 12:59
  • @Angryduck Exactly :( When I would have the source code, just (*.cpp & *.h) without any QtDesginer *.ui , would I be able to use it the QtDesigner then? – Ralf Wickum Jul 22 '15 at 13:04
  • if the entire ui is just created in code from a cpp and a h file then i certainly wouldnt know how to open in designer my instinct is that it cant be done but dont take my work for it, why not just edit it in code? – AngryDuck Jul 22 '15 at 13:36

2 Answers2

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... ?

mikag
  • 162
  • 8
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.

Kuba hasn't forgotten Monica
  • 95,931
  • 16
  • 151
  • 313