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. Basic C++/QML desktop app code review request
Forum Updated to NodeBB v4.3 + New Features

Basic C++/QML desktop app code review request

Scheduled Pinned Locked Moved Unsolved General and Desktop
6 Posts 3 Posters 304 Views 2 Watching
  • 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.
  • M Offline
    M Offline
    michal.19937
    wrote on last edited by
    #1

    Hello, I made a simple app for viewing files in a directory given its path.
    https://github.com/mich19937/Directory-View
    I would be grateful for code review. I have also some questions regarding that code:

    1. Is it better to only connect one big class to QML (like I did) or many smaller (i.e. excluding DirectoryTableModel from AppController, instantiate it in main and connect separately)?
    2. Is there some naming convention for the big class?
    3. Can I use any license I want or am I limited to (L)GPL?
    4. Is there a better way to make a column fill available space in TableView than I did with columnWidthProvider?
    5. Is there a better way to set implicitWidth of TableView's delegate? It looks cumbersome to add margins manually. I tried setting it to childrenRect.width but it's always 0 for some reason.
    Pl45m4P 1 Reply Last reply
    0
    • M michal.19937

      Hello, I made a simple app for viewing files in a directory given its path.
      https://github.com/mich19937/Directory-View
      I would be grateful for code review. I have also some questions regarding that code:

      1. Is it better to only connect one big class to QML (like I did) or many smaller (i.e. excluding DirectoryTableModel from AppController, instantiate it in main and connect separately)?
      2. Is there some naming convention for the big class?
      3. Can I use any license I want or am I limited to (L)GPL?
      4. Is there a better way to make a column fill available space in TableView than I did with columnWidthProvider?
      5. Is there a better way to set implicitWidth of TableView's delegate? It looks cumbersome to add margins manually. I tried setting it to childrenRect.width but it's always 0 for some reason.
      Pl45m4P Offline
      Pl45m4P Offline
      Pl45m4
      wrote on last edited by Pl45m4
      #2

      @michal-19937 said in Basic C++/QML desktop app code review request:

      Hello, I made a simple app for viewing files in a directory given its path.

      Hi and welcome :)

      Is this your first project to learn Qt or programming in general?!

      Haven't checked every single line in detail, but doesn't look too bad.

      You could use QScopedPointer instead of std::unique_ptr as it works better with QObject based classes.

      1. Is it better to only connect one big class to QML (like I did) or many smaller (i.e. excluding DirectoryTableModel from AppController, instantiate it in main and connect separately)?

      Can say much regarding QML as I'm rarely using it.

      1. Is there some naming convention for the big class?

      What "big class"?!
      You can name everything like you want, the "conventions" are all about readability and understanding.
      That it's painful to read the code when you violate these "hints", is a different story :))

      The most important rule, IMO, be consistent.
      If you chose one way of naming your stuff, stick with it, don't change it after X lines of code or X functions or from one file to another and name everything differently afterwards.

      1. Can I use any license I want or am I limited to (L)GPL?

      How is this meant?
      You can publish your app under any license you want, as long as it doesn't violate the (L)GPL Qt modules you have in use, which makes it a bit more tricky.
      Read about Qt's (L)GPL here, esp.

      What are my obligations when using Qt under the LGPL?

      or read the (L)GPL obligations directly here

      As always when it comes to these type of questions: I'm not a lawyer :)
      Ask one if you want to be 100% safe before you even plan to sell your app or something.

      1. Is there a better way to make a column fill available space in TableView than I did with columnWidthProvider?

      See:

      • https://doc.qt.io/qt-6/qml-qtquick-tableview.html#row-heights-and-column-widths

      If debugging is the process of removing software bugs, then programming must be the process of putting them in.

      ~E. W. Dijkstra

      1 Reply Last reply
      0
      • M Offline
        M Offline
        michal.19937
        wrote on last edited by
        #3

        Thanks for the feedback @Pl45m4 . Yes, this is my first Qt project, I have experience with C++ though. Regarding licensing, I've read somewhere that derivative work must be (L)GPL licensed but simply using Qt isn't derivative work, rather combined work, right?

        1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          Hi,

          Warning: I am not a lawyer.

          If one of your dependencies is GPL then your project must be GPL as well. Most other licences allow for other combinations.

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

          M 1 Reply Last reply
          1
          • SGaistS SGaist

            Hi,

            Warning: I am not a lawyer.

            If one of your dependencies is GPL then your project must be GPL as well. Most other licences allow for other combinations.

            M Offline
            M Offline
            michal.19937
            wrote on last edited by
            #5

            @SGaist Ok, but if I only use LGPL modules then I have an LGPL dependecy so I can choose license for my app freely?

            1 Reply Last reply
            0
            • SGaistS Offline
              SGaistS Offline
              SGaist
              Lifetime Qt Champion
              wrote on last edited by
              #6

              There are less constraints. Check for LGPL compatibility.

              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