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
class Box{
private:
SomeQtclass* theQtObject;
bool use_gui;
void drawstuff(){if (use_gui) /*do stuff*/}
void do_random_thing_not_directly_affecting_the_gui();
};
class Box{
private:
SomeQtclass* theQtObject;
bool use_gui;
void drawstuff(){if (use_gui) /*do stuff*/}
void do_random_thing_not_directly_affecting_the_gui();
};
To copy to clipboard, switch view to plain text mode
In the main application I would then have
int main()
{
Box mybox;
cin>>mybox.use_gui;
while (true){
mybox.do_random_thing_not_directly_affecting_the_gui();
mybox.drawstuff();
}
}
int main()
{
Box mybox;
cin>>mybox.use_gui;
while (true){
mybox.do_random_thing_not_directly_affecting_the_gui();
mybox.drawstuff();
}
}
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!
Bookmarks