Basic C++/QML desktop app code review request
-
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:- 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)?
- Is there some naming convention for the big class?
- Can I use any license I want or am I limited to (L)GPL?
- Is there a better way to make a column fill available space in TableView than I did with columnWidthProvider?
- 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.
-
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:- 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)?
- Is there some naming convention for the big class?
- Can I use any license I want or am I limited to (L)GPL?
- Is there a better way to make a column fill available space in TableView than I did with columnWidthProvider?
- 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.
@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 ofstd::unique_ptr
as it works better withQObject
based classes.- 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.
- 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.- 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.- Is there a better way to make a column fill available space in TableView than I did with columnWidthProvider?
See:
-
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?
-
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.
-
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.
@SGaist Ok, but if I only use LGPL modules then I have an LGPL dependecy so I can choose license for my app freely?
-
There are less constraints. Check for LGPL compatibility.