Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Classes organisation - general good practices
Forum Update on Monday, May 27th 2025

Classes organisation - general good practices

Scheduled Pinned Locked Moved Unsolved General and Desktop
good practice
2 Posts 2 Posters 255 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • T Offline
    T Offline
    Thombou
    wrote on 21 Apr 2020, 20:53 last edited by Thombou
    #1

    Hi all, It's the first time I am coding a desktop application.
    I have a few questions about general good practices.
    I want to separate my main window in 3 subparts. On the left, I will have a QTableview. In the center, I will have a form with the details of the selected row of the left part, and on the right I will have a QDialogButtonBox related to the central part.

    I Am quite afraid to code the entire window in the cpp file for the main window as I think there will be a lot of widgets (so I think the file will be very long and maybe not easy to maintain). I am wondering how I should split it, and what should be a dedicated class.

    Is it a good idea to create a separate class for each part of the main window even though they will be connected with a dataMapper? Shall I put everything in a big file?

    Apart from that I will put everything that interacts with the database in a dedicated class.
    Any good practice recommendations to avoid having a unreadable code?

    Also on the database handling. Is it better to create big models that will hold the entire tables (I have 3 main tables) and then filter them out with a proxy model, or shall I create multiple individual lighter requests?

    Thank you
    Thombou

    1 Reply Last reply
    0
    • S Offline
      S Offline
      SGaist
      Lifetime Qt Champion
      wrote on 13 May 2020, 21:11 last edited by
      #2

      Hi,

      Go with the usual: single responsibility. If a widget shall handle a particular aspect then keep it separated with a clean API so can also make it testable.

      For the models, it will highly depend on what you want to access and how you need to interact with it.

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      1

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved