Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

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?

share|improve this question
    
What language are you working with? –  dfarrell07 May 6 '13 at 22:34
    
What language is the Music app? Can you not use bash? –  Freedom_Ben May 6 '13 at 22:34
    
I'm writing in QML. I'm creating a Ubuntu Touch app without C++. And no. No bash. –  Daniel Holm May 6 '13 at 22:37
    
I'd also suggest asking in the ubuntu-touch and ubuntu-touch-coreapps mailing lists, which is where the SDK developers hang out. –  David Planella May 7 '13 at 16:02
    
Maybe if you tell us why you need the user name and the path to their home folder someone might come up with a workaround or another way to do it. –  David Planella May 7 '13 at 16:04

2 Answers 2

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.

share|improve this answer
    
Thank you. I was afraid of that. I'll give it a go on Stack Overflow. –  Daniel Holm May 7 '13 at 7:59

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++.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.