views:

1601

answers:

3

I'm starting a C++ project using OpenGL and Qt for the UI in eclipse. I would like to create a UI where a portion of the window contains a frame for OpenGL rendering and the rest would contain other Qt widgets such as buttons and so on.

I haven't used Qt or the GUI editor in eclipse before and I'm wondering what the best approach would be? Should I create the UI by hand coding or would it be easier to use eclipse's GUI designer - I had a quick look at this and there doesn't seem to be an OpenGL widget built in.

Thanks

A: 

Why won't you use Qt Eclipse Integration? It works flawlessly, enables you to edit UIs directly from Eclipse.

Marcin Gil
i am using that...
Tarski
A: 

I had the same problem, while using Qt Designer. I used a simple frame as a placeholder for the OpenGL widget, then, in main window constructor, I created OpenGL widget manually and assigned it to the placeholder frame (as a child).

The main advantage here is that you see, where the OpenGL widget should be while designing your interface. The main disadvantage is that some coding is still required to set up the GUI.

+6  A: 

If you are using Qt Designer (which I think is available via Eclipse Integration), you can place a base QWidget in the layout and then "promote" that widget to a QGLWidget. To do this:

  1. Add the QWidget to the desired place in the layout
  2. Right-click on the widget
  3. Select "Promote To"
  4. Enter QGLWidget as the class name and as the header
  5. Hit Add
  6. Select the QGLWidget from the list of promoted widgets at the top of the dialog
  7. Hit Promote

This way you don't have to go through the placeholder route and create an additional layer.

Joe Corkery
Thanks. That was just what I was after :-)
Tarski