I'm working on the Music app and I need to know how to get the user name and/or home dir of the users. I've googled around for a while but can only find the variables for C++ or BASH.
How do I get the user name or his/her home dir?
I'm working on the Music app and I need to know how to get the user name and/or home dir of the users. I've googled around for a while but can only find the variables for C++ or BASH.
How do I get the user name or his/her home dir?
I do not believe there is any way to do this using QML only, without C++. I am a C++ Qt developer, but I don't use QML much, so there may be some way that I am not aware of.
My understanding of QML is that it is primarily used for describing a UI for which any non-trivial backend code is implemented in either PyQt or C++. Additionally, QML is meant to be completely cross-platform, and obtaining a User ID is not a platform agnostic operation.
If I were you and I was set on not using C++, I might try asking this question on Stack Overflow. There may be someone there with more expertise.
Thanks to Amit Tomar for this answer:
You would have to get the Username in C++ and then exchange that data from C++ to qml.
QML and C++ objects can communicate with one another through signals, slots and property modifications. For a C++ object, any data that is exposed to Qt's Meta-Object System - that is, properties, signals, slots and Q_INVOKABLE methods - become available to QML. On the QML side, all QML object data is automatically made available to the meta-object system and can be accessed from C++.
Read here how to exchange data between QML and C++.