Create icons button in a grid that connect to applications in a folder
-
I am trying to create a simple application that contains a group of icons in a grid. These icons would link to applications(exes) i place in a folder
I am working on the photoviewer example and trying to figure out how i can link the pictures to open the process(an exe) but unsure how to do link a qml object from the main and load a exe with Qprocess. Ultimatly I would like it to dynamic load the exes i am interested in but currently i am content with hardcoded paths.
I am mainly a C++ developer and I am trying out qt to see if it is suitable for further use but it seems pretty overwhelming. I am trying to do my application over an example but it seems like there is a thousand ways to skin the cat which kinda impedes my learning as sometimes it gets confusing with the different file types in different examples like the qml,moc,qm files. Any tips on the best way to approach my particular problem?
-
@dashtag This book may help you learn QML https://qmlbook.github.io.
As for all the different file types and technologies. You don't need to use all of them. You could use QML for your UIs or you could do it with QtWidgets in C++. I use both for different things. For this project it sounds like QML would be good for you though. It would be very easy to make a nice looking interface with those requirements.
As for linking C++ and QML, it is quite easy. Here is a quick example main.cpp that would load your qml:
#include <QGuiApplication> #include <QQmlApplicationEngine> int main(int argc, char **argv) { bool shouldExit = false; QGuiApplication app(argc, argv); QQmlApplicationEngine engine; QObject::connect(&engine, &QQmlApplicationEngine::objectCreated, [&shouldExit](QObje // load our main window engine.load(QUrl("qrc:///qml/main.qml")); // if mainwindow failed to load, exit if (shouldExit) return 1; return app.exec(); }
The QML is in a QRC file which is just a resource file. If you're familiar with visual studio it is like a .rc file. You can use raw QML on the file system too, you don't need it in a QRC.
If you need more info on connecting objects from QML to C++ let me know and I can show you an example of that as well.
Finally, Qt is a large and very mature library. It has been around for 20 years or so. Actively developed the whole time. It is not something you will learn over night but it is an amazing library that will definitely benefit you and your company. Once I learned it I never looked back. That was 16 years ago. It's worth it! :) I now hate getting contracts or projects where I can't use it.