Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

How to create multiple applications that all look alike?



  • I'm a C++ teacher that has very little experience so far with Qt. I'd like to create lots of small Qt desktop applications with basic functionality, so students can complete/augment the C++ code, make each application functional and (hopefully) learn a lot about C++ in the process. Things to learn are simple C++ basic constructs like for-loops, (do)while, if/else, data types, etc. We've all been there, haven't we?

    Now I'd like to learn what would be the best way to build all these small applications using a "template" or some other construct, so they will all look more or less the same. I've setup a subfolder-project and created a Qt Widgets application that was supposed to serve as the superclass, where I would subclass this for each exercise's application. This turned out to be quite hard, but it seemed the most 'clean' and OO solution to me. If I wanted to change the appearance of all the applications I'd have only one place where I would have to implement the change, is what I thought. It's not working by now, but if this turns out to be the best solution I'll go for it and tweak it until it works.

    But then I started to wonder whether there would be other ways? For instance: I might write exactly one Qt Widget main window application and somehow get the exercises as 'plugins' into this framework. But would I be able to use the form builder in Qt Creator to build these plugins?

    Thanks in advance for any hints and/or pointers!

    Regards,
    Joost



  • I'm mostly going to echo what has been said already, but in my own words.

    Subclassing the application class feels too heavy-handed to me.

    Plugins are "getting closer" to something that would feel better, but creating a (dynamically loaded DLL-type plugin) is rather advanced, so I would avoid that.

    Indeed it does sound like you really just want one app, where maybe you use a Tabbed UI (like browser tabs), and each exercise is simply a panel that gets added as a new tab.

    Having a git repo is a great idea. If you are up for the extra up-front work, you could provide a repo that already contains a handful of well-crafted commits. For example: if the most recent commit is "adds the third tab", then you can demonstrate how to use "git difftool" to examine that one commit, so that students see that the diff of "adds the third tab" is a handy cheatsheet showing exactly how to add a new tab.

    Really, kudos to you for ALL your effort so far. Computing/programming education is important, and you are going above and beyond!



  • Might be a bit of an overkill but why not a template app as a git repo and separate branches per student? They could learn basics of git that well (I'd like to perceive that as an added value rather then additional difficulty). You could review that as they make pull requests...


  • Lifetime Qt Champion

    Hi
    Just as a note.
    If the goal is to teach basic and not anything Qt/UX related why not simply make one app that provides an easy way to see output
    on screen. ( like PlainTextEdit)
    and setup UI and such so students would only have to add that basic code and can use provided output function that goes to this
    on-screen widget.
    You can have an empty slot for clicking on a button and they can fill in their code there
    and press button to run it and see out put.

    Then they can focus on adding basic c++ and not care about the Qt part.

    also, using GIT as @artwaw suggest, would give them a taste of real life so to speak. :)



  • I'm mostly going to echo what has been said already, but in my own words.

    Subclassing the application class feels too heavy-handed to me.

    Plugins are "getting closer" to something that would feel better, but creating a (dynamically loaded DLL-type plugin) is rather advanced, so I would avoid that.

    Indeed it does sound like you really just want one app, where maybe you use a Tabbed UI (like browser tabs), and each exercise is simply a panel that gets added as a new tab.

    Having a git repo is a great idea. If you are up for the extra up-front work, you could provide a repo that already contains a handful of well-crafted commits. For example: if the most recent commit is "adds the third tab", then you can demonstrate how to use "git difftool" to examine that one commit, so that students see that the diff of "adds the third tab" is a handy cheatsheet showing exactly how to add a new tab.

    Really, kudos to you for ALL your effort so far. Computing/programming education is important, and you are going above and beyond!


  • Lifetime Qt Champion

    Hi,

    You might want to check this project that provides a cookiecutter template for Qt apps. It's tailored to the author taste but might give you a good starting point.



  • @artwaw Good idea, but since the semester I am working on already is quite loaded with knowledge (I forgot to mention that they are supposed to learn OpenCV together with C++) I won't be able to learn them the basics of Git, other than just cloning my repository so that they have all the assignment code at once. Would love to teach them more about Git though, since even mechatronics engineers sometimes write huge amounts of software, they need to work together with other people, etc.



  • @mrjj Funny, this is exactly one of the first approaches I chose. For basic input/output programming a simple console-like window is fine. Most of the available course material is currently (we're speaking 2020...) still based on cin and cout, but I think it is time to finally move further towards real GUI programming. But for simple exercises, it's fine. Like this:

    Screenshot from 2020-05-29 21-13-43.png

    (oh, and 'Sommen' means 'Calculations' in Dutch :-)



  • @KH-219Design I think I will further investigate the option of having multiple tabs with different output windows, and menu items for each assignment they have to complete. I forgot to mention that they are learning C++ in the context of machine vision, so a lot of their attention already goes to OpenCV. For advanced Git, there is no space, sadly, other than them cloning the repository. But it might be a start! I am working on the mechatronics department of a university of applied sciences. Having a software development background and past career myself, I think there is quite a lot to improve (and this definitely involves knowledge of Git!).


  • Lifetime Qt Champion

    @Joost-van-Stuijvenberg
    Hi
    That is super good to hear as cin and cout is mostly fun with console apps
    and a hint of GUI programming should be
    possible without going into details too much.
    Also could fit in well with openCV as for debug output etc.



  • @SGaist I'll look into it, thanks!


Log in to reply