Results 1 to 4 of 4

Thread: probably a stupid question...

  1. #1
    Join Date
    Aug 2006
    Location
    troy, new york
    Posts
    24
    Thanks
    4
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default probably a stupid question...

    the thing is that when i start my app from the command line it finds and opens the right files but when i click on the app icon in a window manager (gnome/kde), they don't. do i have to use QDir? thanx.

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,364
    Thanks
    3
    Thanked 5,012 Times in 4,791 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: probably a stupid question...

    You use relative paths. When you click the app icon in the file manager, the current directory is set to your home dir and your application can't find the files it needs. You should either change the current directory back in your app or (what is better) use absolute paths. QCoreApplication::applicationDirPath() may be helpful here.

  3. #3
    Join Date
    Aug 2006
    Location
    troy, new york
    Posts
    24
    Thanks
    4
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default Re: probably a stupid question...

    i tried to set it with QCoreApplication::applicationDirPath() but i couldn't get it through main(); i finally solved it with QDir setPath in my class implementation :

    Qt Code:
    1. QDir d;
    2. d.setPath("/path/to/file/");
    3. QFile file(d.filePath("in.txt"));
    To copy to clipboard, switch view to plain text mode 


    if you could provide a snip for main() i'll give it a shot. thanx again

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,364
    Thanks
    3
    Thanked 5,012 Times in 4,791 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: probably a stupid question...

    Qt Code:
    1. QString mypath = QCoreApplication::applicationDirPath()+"/myimage.png";
    To copy to clipboard, switch view to plain text mode 

Similar Threads

  1. QThread exit()/quit() question
    By TheKedge in forum Qt Programming
    Replies: 1
    Last Post: 28th August 2006, 14:38
  2. simple thread layout question
    By mhoover in forum Qt Programming
    Replies: 1
    Last Post: 12th August 2006, 11:02
  3. Basic question on new and delete
    By jcr in forum General Programming
    Replies: 25
    Last Post: 14th February 2006, 15:09
  4. simple question on Class-Members
    By mickey in forum General Programming
    Replies: 7
    Last Post: 4th February 2006, 22:37
  5. xml with binary question
    By TheKedge in forum Qt Programming
    Replies: 7
    Last Post: 12th January 2006, 23:21

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.