c++ - Connecting the GUI and Calculations in Qt Application -
i writing qt application calculations. to separate in project 2 parts: part related gui , part responsible calculations. recommend best way so? examples appreciated.
my idea in main.cpp file:
int main(int argc, char *argv[]) { qapplication app(argc, argv); mainwindow mw; // responsible gui mw.show(); maincomputation mc; // responsible calculations return app.exec(); }
i need establish connections between 2 parts.
you need create maincomputation
class shown here (mainly inherit qobject
, include q_object
macro in class declaration , label methods slots).
then need hook signals , slots between gui elements signals (mouseclick, buttonpress, etc..., checkout each widgets available signals) , instance of maincomputation
objects slots. done connect
statement. kinda this
connect(mw.ui->btn,signal(clicked(bool)),&mc,slot(dosomething()));
there simple example lot of information available @ qt docs.
Comments
Post a Comment