I got 7 different features on my main window of my application, how to seperate my code for each feature?
So i have a main window with 7 different features, so mainwindow.cpp is filled with code from every feature. But this makes the code unreadable (like when u want to know how one of the feature is made you must search trought everything), and i was thinking to seperate the code somehow.
1st thing i thought was to use classes, but when i need for example a timer that has been declared on another class i will need to use signals etc everytime in order for the classes to communicate.
2nd was seperate cpp files, but its the same
3rd and the most simple was to use acci letters something like:
Any other suggestion?
you can separate your code in multiple header (.h) files..
//in mainwindow.cpp :-
#include MyTimer ;
class MyTimer : public Qtimer(......)
if MyTimer needs something (a class, variable... etc) from other file you can just declare it and leave the definition where it is (supposing that it's already defined in where you're using class MyTimer)
for example if MyTimer needs a class named class_1 you can write this in MyTimer.h file:-
class class_1 ;
class MyTimer : public Qttimer(......)
class_1 *object_1 = new class_1();
The most straight forward (not saying it's easy) is to encapsulate each feature in it's own class so they might also become reusable.