I just created my first non-hand-coded Qt GUI using Designer but I don't know how to use the result in my other QDialog derived C++ class. I created a complex widget using Designer and this resulted in a VisControls.ui file. After it compiled, I had ui_VisControls.h which contains the UI code with 2 classes: Ui_VisControls and an emty class Ui::VisControls : Ui_VisControls.

I tried:

#include "GeneratedFiles/ui_VisControls.h"
using Ui;
...
VisControls *w = new VisControls();
w->Show();

Then got the compiler error 'Show' is not a member of Ui::VisControls. This makes sense because nowhere in the generated files that I can find is there a " : QWidget" making the class I created derive from QWidget. Neither Ui_VisControls or Ui::VisControls derives from QWidget. Since the ui_VisControls.h file is regenerated when I compile, I can't very well add " : QWidget" there.

All I am looking for is how to take the output of Designer and then instantiate QWidget-derived classes. That is, how do I plug the results of Designer into my applications?

I've been using Qt in Visual Studio 2008 Standard for a couple of months with no problems.

I must be making a simple mistake because the property editor in Designer has QWidget attributes. I saw no place in Designer where I could specify the base class when creating my new Form.

Sorry for the dumb question! Below is the code where I want to display my form. The .ui and generated .h files are too large to attach in this forum so I included excerpts below.

Thank you in advance. I have looked at this problem for hours but to no avail.

Rick

------------------------------------------------

ui_VisControls.h excerpt:

Qt Code:
  1. #ifndef UI_VISCONTROLS_H
  2. #define UI_VISCONTROLS_H
  3.  
  4. #include <QtCore/QVariant>
  5. #include <QtGui/QAction>
  6. #include <QtGui/QApplication>
  7. #include <QtGui/QButtonGroup>
  8. #include <QtGui/QDoubleSpinBox>
  9. #include <QtGui/QGroupBox>
  10. #include <QtGui/QHeaderView>
  11. #include <QtGui/QLabel>
  12. #include <QtGui/QPushButton>
  13. #include <QtGui/QSlider>
  14. #include <QtGui/QSpinBox>
  15. #include <QtGui/QWidget>
  16.  
  17. QT_BEGIN_NAMESPACE
  18.  
  19. class Ui_VisControls
  20. {
  21. public:
  22. QGroupBox *groupBox;
  23. QSlider *cameraPositionXSlider;
  24. QSlider *cameraPositionXYSlider;
  25. QSlider *cameraPositionZSlider;
  26. < many more lines... >
To copy to clipboard, switch view to plain text mode 

------------------------------------------------

Here is an excerpt from the .ui file:

Qt Code:
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <ui version="4.0">
  3. <class>VisControls</class>
  4. <widget class="QWidget" name="VisControls">
  5. <property name="geometry">
  6. <rect>
  7. <x>0</x>
  8. <y>0</y>
  9. <width>281</width>
  10. <height>761</height>
  11. </rect>
  12. </property>
  13. <property name="windowTitle">
  14. <string>VisControls</string>
  15. </property>
  16. <widget class="QGroupBox" name="groupBox">
  17. <property name="geometry">
  18. <rect>
  19. <x>10</x>
  20. <y>10</y>
  21. <width>261</width>
  22. <height>81</height>
  23. </rect>
  24. </property>
  25. <property name="title">
  26. <string> Camera Position </string>
  27. </property>
  28. <widget class="QSlider" name="cameraPositionXSlider">
  29. <property name="geometry">
  30. <rect>
  31. <x>30</x>
  32. < many more lines >
To copy to clipboard, switch view to plain text mode 

------------------------------------------------

This is the place where I attempted to use the Designer-generated class:

Qt Code:
  1. #include "GeneratedFiles/ui_VisControls.h"
  2. using namespace Ui;
  3. ...
  4. void OpenGLDlg3::test1ButtonPressed() {
  5. VisControls *w = new VisControls();
  6. w->Show();
  7. emit test1();
  8. }
To copy to clipboard, switch view to plain text mode