Results 1 to 3 of 3

Thread: QPushButton question

  1. #1
    Join Date
    Mar 2009
    Posts
    4
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default QPushButton question

    Hi all,
    I'm getting crazy with an annoying behaviour in my app.
    This app has a menu with some QPushButton button, with a icon inside.
    If I click on my app, it starts but, when the menu pops-up, only the buttons appear, not the icon ...
    If i launch my app from console, like
    Qt Code:
    1. alex@laptop:$ ./myapp
    To copy to clipboard, switch view to plain text mode 
    everything works fine, and the buttons are displayed with their icons =\
    I know that is stupid, but I can't fix it!
    Any suggestion ??

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

    Default Re: QPushButton question

    You are using relative paths to icons in your application. When you start it from the console, the current directory is not changed and the paths are preserved. If you start the program by clicking on it using a file manager, the current directory is most probably set to your home directory and your application is unable to find the files anymore. Either use absolute paths or use QCoreApplication::applicationDirPath() and provide paths relative to your application's binary. Alternatively you can embed the icons directly into the application itself by using Qt's resource system.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  3. #3
    Join Date
    Mar 2009
    Posts
    4
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: QPushButton question

    Thank you wysota, now I'll try with QCoreApplication::applicationDirPath()
    Resources are an other feature I want to implement in my app, in order to reduce the number of sparse files... but up to now, I've found few examples about managing them with cmake ... and also very aproximative ...
    However, again : thank you !!!!

Similar Threads

  1. QPushButton not calling repaint when needed?
    By Enygma in forum Qt Programming
    Replies: 5
    Last Post: 13th May 2010, 17:03
  2. QWidget::setTabOrder question
    By graciano in forum Qt Programming
    Replies: 2
    Last Post: 14th January 2009, 22:46
  3. Qpushbutton
    By iamhere in forum Qt Programming
    Replies: 5
    Last Post: 15th October 2008, 04:40
  4. QPushButton question...
    By JonathanForQT4 in forum Newbie
    Replies: 3
    Last Post: 26th April 2007, 14:50
  5. Replies: 3
    Last Post: 26th September 2006, 12:16

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.