First, to describe my setup, I'm using Qt 4.1 patched in with VS2005 on Windows XP.

I've been using Qt for a couple day now, and have managed to run into troubles early.
I'm trying to dynamically load my Qt Designer-created QMainWindow, much like the Calculator Builder example does with a QWidget. I can compile and use the calculator perfectly.
I figure changing the parent class and a couple ctor items should work for a QMainWindow...right?

Here's essentially what I'm working with:

Qt Code:
  1. class MainForm : public QMainWindow
  2. {
  3. public:
  4. MainForm(QMainWindow *parent = 0);
  5. }
To copy to clipboard, switch view to plain text mode 

Qt Code:
  1. MainForm::MainForm(QMainWindow *parent) : QMainWindow(parent)
  2. {
  3. QUiLoader loader;
  4. QFile file(":/forms/mainwindowgui.ui");
  5. file.open(QFile::ReadOnly);
  6. QWidget *formWidget = loader.load(&file, this);
  7. file.close();
  8.  
  9. QLayout *layout = new QVBoxLayout;
  10. layout->addWidget(formWidget);
  11. setLayout(layout);
  12. }
To copy to clipboard, switch view to plain text mode 

And the main.cpp remains the same as the calculatorbuilder example.

This seems simple, but clearly I'm missing something crucial. Any input is appreciated. Thanks.