Refactoring a huge mainwindow
-
My mainwindow.cpp file is getting incredibly large (32 slots and 1000+ lines so far) and although it's OK at the moment, I can see it getting a nightmare to maintain very soon. I was wondering if any Qt experts have any recommendations for how to go about refactoring large QMainWindow classes?
Keep in mind I have other classes doing the backend work - the mainwindow class deals just with the GUI logic for talking to the backend objects so most of the methods are only a few lines. The problem is that it has a number of tab and stacked widget pages, and each of them has enough logic to be a small application in its own right. Any ideas on how to split this up nicely?
Cheers,
Matt -
-
[quote author="Gerolf" date="1293054565"]Hi Matt,
refactor by extract Class method:
- Make the tabs / widgets / pages in the stack own classes.
Cheers
Gerolf[/quote]Agree. That's the best solution.
I'm working on a similar project, where the MainWindow has at least 50 different pages. Most of them are similar (showing a list of customer, a list of suppliers, etc) so I have a QAbstractPage class, and I subclass for every different page.