![]() Registered Member ![]()
|
[SOLVED] currentPath doesn't work using KDE (Using GNOME or Windows it works)
Sun May 24, 2009 3:16 pm
Hi everyone!
First. I'm new in this forum and I was looking for my problem too much but I didn't found anything, so excuseme if this thread is a repeated thread (sorry). Second. I'm from Spain, so sorry for my bad english ![]() Ok, the problem is the next. I'm currently developing a Qt application (without kde libs), and the app was compiled and can run in KDE, GNOME and Windows. Everything is ok in GNOME and Windows, but I've a problem with KDE. I have a sub-folder in my project: Folder "Files", with two txt files with some initials configurations. The folder have to be in the same path where the binary is, and everything should works... but in KDE it doesn't. It is because in Konqueror and Dolphin, when I execute the binary doing double click, they "tell" to the app that the binary is always in my home path (and that's not true) so my app can not read the files in the sub-folder (I use QDir dir = QDir::currentPath()). I did a simply test: I made the following script:
I gave execute permissions to the script and i did double click on it using dolphin. The result: It creates always a "dir.txt" in my home with the Home Path writed in it. It doesn't matter where the script is, because always do the same... in my home. I tried the script with Nautilus and Thunar and it works like I want (making a dir.txt in the script's path with that path writed in it). And like I said before my app works fine in GNOME and Windows but not in KDE cause that. Is that a KDE bug or only a KDE "peculiarity"? is very strange because last year I saw the same with other project. PD: It occurs in KDE 4 and also in KDE 3. Tested in Suse 11.1, Mandriva 2008.1, and Kubuntu 8.04 Can anyone help me? Should I create a bug issue in the bug tracker and wait?, are there any solution to know where a script/binary is doing double click? Thank you!!
Last edited by Alesete on Sun May 24, 2009 3:25 pm, edited 1 time in total.
|
![]() Registered Member ![]()
|
[SOLVED] currentPath doesn't work using KDE (Using GNOME or Windows it works)
Sun May 24, 2009 3:31 pm
It's better than my Spanish:-P
Your problem is because Dolphin is "in" your home directory, so the current directory (as found by pwd) is always that. You can prove this by opening a terminal typing "cd /tmp" and then "dolphin". Double click on your script and it will write "/tmp" as the current directory. In the settings for the icon you've (I assume) set up for your application (or menu option) you need to set the "Work path" to the directory you want it in. That should then (I think) sort out what you're trying to do. |
![]() Registered Member ![]()
|
[SOLVED] currentPath doesn't work using KDE (Using GNOME or Windows it works)
Sun May 24, 2009 4:36 pm
Is not a good idea trusting in desktop for this stuff. You can try the next few lines and use it in your scripts:
Works even with symlinks ![]() I think that with Qt the process will be the same. Oh, I'm from A Coruña ![]() Yes, I check Qt docs and found something http://doc.trolltech.com/4.5/qcoreappli ... ionDirPath
Last edited by Ignacio Serantes on Sun May 24, 2009 10:36 pm, edited 1 time in total.
Ignacio Serantes, proud to be a member of KDE forums since 2008-Nov.
|
![]() Registered Member ![]()
|
[SOLVED] currentPath doesn't work using KDE (Using GNOME or Windows it works)
Sun May 24, 2009 9:59 pm
Hi again! Thank you very much for yours responses.
I've solved that by the Ignacio's way. It works now ![]() In my qt code I've changed this:
to this:
And now everything works fine ![]() the script works also, I'll keep it in some secure place for use it in the future :-P beermad:
It still creating "dir.txt" file in the home with the home path writed inside... ![]() But thank you very much for your response ![]() Regards and thank you again guys! PD: Oh, I'm from Málaga, but I like very much the "Gallegos" people ![]() |
![]() Registered Member ![]()
|
RE: [SOLVED] currentPath doesn't work using KDE (Using GNOME or Windows it works)
Sun May 24, 2009 10:41 pm
I forgot quotes in the script and without then if path or file name has spaces the code fails
![]()
Ignacio Serantes, proud to be a member of KDE forums since 2008-Nov.
|
Registered users: Bing [Bot], Google [Bot], Sogou [Bot]