tags:

views:

69

answers:

1

I'm not sure how to ask this, but here goes the question:

I'm migrating from J2SE to Qt. After creating some small applications in Qt, I noticed that I've created way too many files compared to what I would've create if I was developing in Java (I use Netbeans).

For an example, for a GUI to Orders, I'd have to create

  1. Main Order Search Window
  2. Edit Order Dialog
  3. Manage Order Dialog
  4. Maybe some other dialogs...

For Java, I don't have to create a new file for every new Dialog, the Dialog will be created in the JFrame class itself. So, I will only be seeing 1 file for Orders which has other Dialogs in it. However, in Qt, I'd have to create 1 ui file, 1 header file, 1 cpp file for each of the Dialog (I know I can just put the cpp in the header, but it's easier to view codes in seperate files). So, in the end, I might end up with 3 (if there are 3 dialogs) x3 files = 9 files for the GUI in Qt, compared to Java which is only 1 file.

I do know that I can create a GUI by coding it manually. But it seems easy on small GUIs but not some on complicated GUIs with lots of inputs, tabs and etc.

So, is there any suggestion on how to minimize the file created in Qt?

+3  A: 

Mostly you have to create more files because in C++ you should separate you class interface from implementation and because files created by designer a processed by some code generation utility which creates C++ header file.

You can put all classes definitions in one header and all implementations in another one and for 3 dialogs you'll have 3 ui files + 2 source files (one header and one cpp file) but such putting all code together makes navigation through the project more complicated. In straight forward way you create more files containing less code but it's really simple to find file responsible for certain dialog behavior when you doing refactoring, bugfixing or when somebody else reads you code in order to join the project.

VestniK