Results 1 to 4 of 4

Thread: Organizing program structure so that it is easy understandable

  1. #1
    Join Date
    Feb 2008
    Posts
    79
    Thanks
    8
    Qt products
    Qt4
    Platforms
    Windows

    Default Organizing program structure so that it is easy understandable

    Hello,

    I am writing a program that is using qtabwidget as a main navigation tool. There is a lot of widgets on each screen and also dialogs that open when user presses some buttons etc.

    Now I am facing a problem that I dont know how exactly I should organize code to keep it simple, organized and understandable. Obviuosly code for widgets on all tabs belongs to the same class, because everything what is on different tabs belong to same GUI class. What would you suggest to organize this properly? So that I can divide code for each tabs into maybe different directories or files? I already tried with #include directives but it is very dirty and does not actually work.

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Organizing program structure so that it is easy understandable

    Quote Originally Posted by Tiansen View Post
    Obviuosly code for widgets on all tabs belongs to the same class, because everything what is on different tabs belong to same GUI class.
    That's a bad idea. Each tab should be in each own class. The fact that they belong to the same GUI is meaningless.
    Objects should be able to cooperate using a well design API with signals and slots.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  3. #3
    Join Date
    Feb 2008
    Posts
    79
    Thanks
    8
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Organizing program structure so that it is easy understandable

    That's a bad idea. Each tab should be in each own class.
    I agree totally with you. I am just saying that if you use Qt Designer to build GUI, you get only one GUI class for all tabs when using QTabWidget. So there is a way to assign different classes to different tabs?
    I think that I must do following then:

    1. Make GUI class for each desired tab.
    2. Design GUI part of each class (can be done with Designer too).
    3. Then assign these GUI classes to each tabs (I think this must be done with code, because Designer doesnt support it).

    Am I correct here?

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Organizing program structure so that it is easy understandable

    Quote Originally Posted by Tiansen View Post
    I agree totally with you. I am just saying that if you use Qt Designer to build GUI, you get only one GUI class for all tabs when using QTabWidget.
    No, that only happens if you do everything inside one form.

    So there is a way to assign different classes to different tabs?
    Yes, at least two such ways. One is to design each tab as a separate widget and then create a QTabWidget in manual written code and add those tabs to the widget there. The other is to make each of your pages a custom widget (either through plugins or by promoting the base class to the custom class) and make a form containing QTabWidget and place those custom widget as pages on the form. The first approach is better because you end up with a simpler hierarchy of objects.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


Similar Threads

  1. General: Structure of a Qt mainwindow program
    By kaizimir in forum Newbie
    Replies: 6
    Last Post: 7th September 2009, 18:33
  2. Some advice on how to structure this program?
    By mrwooster in forum Newbie
    Replies: 13
    Last Post: 12th August 2009, 14:24
  3. QTextEdit... was ->text() too easy?
    By Raccoon29 in forum Newbie
    Replies: 2
    Last Post: 16th March 2008, 16:58
  4. yet another easy task i cant figure out
    By sincnarf in forum Qt Programming
    Replies: 5
    Last Post: 16th October 2007, 05:46
  5. Organizing multiple threads
    By vratojr in forum Qt Programming
    Replies: 3
    Last Post: 25th May 2006, 09:53

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.