I wish to write a totaly simple C++ class. It should contain a pointer to a QMainWidget (or another suitable Qt object) and if a certain bool variable is set to false the pointer should be 0 or else it should point to a qtobject that contains three buttons and a big area where I can draw stuff.

Like this
Qt Code:
  1. class Box{
  2. private:
  3. SomeQtclass* theQtObject;
  4. bool use_gui;
  5. void drawstuff(){if (use_gui) /*do stuff*/}
  6. void do_random_thing_not_directly_affecting_the_gui();
  7. };
To copy to clipboard, switch view to plain text mode 

In the main application I would then have
Qt Code:
  1. int main()
  2. {
  3. Box mybox;
  4. cin>>mybox.use_gui;
  5. while (true){
  6. mybox.do_random_thing_not_directly_affecting_the_gui();
  7. mybox.drawstuff();
  8. }
  9. }
To copy to clipboard, switch view to plain text mode 

The Box class should be a kind of class that could be included in many other programs, like std::string.

How do I write this kind of code? I need some kind of QApplication, right? Where do I put it?
Anyone with idas, please speak up!