Results 1 to 8 of 8

Thread: Sames executable, different behaviours...

  1. #1
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Sames executable, different behaviours...

    Hi,

    I have the following problem:
    I am coding a Qt4.1.0 project with KDevelop3.3.1 on KDE3.5.1, SUSE10.
    In that project I have a dialog with a QLabel.
    In my dialogs implementation (the dialog is design with designer), I added a setPixmap() to my label with an image.
    Now:
    If I start the application from the console, the pixmap in my QLabel does not show up.
    If I start the application with "Execute main program" within KDevelop, it also , wont show the pixmap.
    However, if I start the application with "Execute subproject" within KDevelop, the pixmap is shown. (the main project is the "subproject" then)

    Since I had to reinstall my SUSE, there is a small chance it has to do with a somehow bad installation.
    Therefore, I attach here my project, and if any one here has a similar system and could just built and run it and say if he gets the same behaviour would help to eliminate or confirm the option of bad OS.

    Other then that, if anyone here has an idea what this could be, please share.

    Thanks in advance.
    Attached Files Attached Files

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Sames executable, different behaviours...

    imagePanel.label->setPixmap(QPixmap("round_blue.png")); //using resources didn't help
    You are using a path that is relative to current working directory --- no wonder it sometimes doesn't want to show up.

    Remove the leading slashes from paths in sharpeye.qrc and try QPixmap(":/res/bt_maximize_press.png").

  3. #3
    Join Date
    Feb 2006
    Location
    Boulder, Colorado, USA
    Posts
    63
    Thanked 8 Times in 5 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Sames executable, different behaviours...

    You aren't using the resource, you are using the files directly. since the paths you gave for the images were relative, it depends on the directory that you launch the appliction for the paths to match up.

    To use the resources you need to prefix the path with a colon.

    as in: setPixmap(QPixmap(":/res/round_blue.png"))

    Also, I find that qt is more consistant if in the qrc file I use <qresource prefix="/" > rather than <qresource >

  4. #4
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: Sames executable, different behaviours...

    Quote Originally Posted by jacek
    You are using a path that is relative to current working directory --- no wonder it sometimes doesn't want to show up.

    Remove the leading slashes from paths in sharpeye.qrc and try QPixmap(":/res/bt_maximize_press.png").
    The code you see here (in the attached zip) was my last try...
    My original code was with resources (mybe parts ares still commented there).
    So, the above code you suggested was the first thing I tried...
    If you use my project with resouces the way you suggested above, does it work for you?
    But never the less it looks like it really is a realtive/absolute path problem, which makes sense anyhow.
    I'll look again in to it, maybe I had a stupid typo somewhere...
    P.S
    But what about when I choose a pixmap from designer?
    Then I have no influence on the image path, I can only choose the file, but how the path is saved is totally up to designer, and that behaves also as I explained above...

    Thanks!!
    Last edited by high_flyer; 10th March 2006 at 09:11.

  5. #5
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Sames executable, different behaviours...

    Quote Originally Posted by high_flyer
    If you use my project with resouces the way you suggested above, does it work for you?
    Of course it works --- read carefully the beginning of the last sentence in my previous post (the one about removing leading slashes).

    But what about when I choose a pixmap from designer?
    It should work too, but I had to fix .qrc at least once.

    Here's example of my .qrc file:
    xml Code:
    1. <RCC>
    2. <qresource prefix="/" >
    3. <file>data/ciexyz</file>
    4. ...
    5. <file>icons/open.png</file>
    6. ...
    7. </qresource>
    8. </RCC>
    To copy to clipboard, switch view to plain text mode 
    I can access these resources using ":/data/ciexyz" or ":/icons/open.png" and they work also with Designer.

  6. The following user says thank you to jacek for this useful post:

    high_flyer (10th March 2006)

  7. #6
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: Sames executable, different behaviours...

    Just wanted to say thank you to who responded.
    I must have had some typo before when I used the resources...
    Any way now it works as it should.
    Thanks!

    P.S
    One more question though...
    Why prefix "/" works for folders under my project root and not under the "real" root "/"?
    This means that the qrc file always looks from its own location (or project root) and lower.:
    so "/home/name" will be infact "project_location/home/name"...
    But what if I have a general resource folder that is above my project root, what then?

    I know in fact this is not the case, its not logical.
    I know that prefix="/home/name" will indeed go to the right folder, not under my project, but why then "/" works?
    Last edited by high_flyer; 10th March 2006 at 19:12.

  8. #7
    Join Date
    Feb 2006
    Location
    Boulder, Colorado, USA
    Posts
    63
    Thanked 8 Times in 5 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Sames executable, different behaviours...

    Quote Originally Posted by high_flyer
    Just wanted to say thank you to who responded.
    I must have had some typo before when I used the resources...
    Any way now it works as it should.
    Thanks!
    You're welcome.
    Quote Originally Posted by high_flyer
    P.S
    One more question though...
    Why prefix "/" works for folders under my project root and not under the "real" root "/"?
    This means that the qrc file always looks from its own location (or project root) and lower.:
    so "/home/name" will be infact "project_location/home/name"...
    But what if I have a general resource folder that is above my project root, what then?

    I know in fact this is not the case, its not logical.
    I know that prefix="/home/name" will indeed go to the right folder, not under my project, but why then "/" works?
    The prefix has nothing to do with the filesystem. It is more like a namespace. You can define the prefix to be whatever, so that you avoid name collisions or for convenience. So prefix="/someRandomName", allows you to access :/someRandomName/myfile.png. This might be useful if you have multiple resource files each accessing their contents from paths that look the same with respect to their locations.

  9. The following user says thank you to jrideout for this useful post:

    high_flyer (13th March 2006)

  10. #8
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: Sames executable, different behaviours...

    I need to revive this thread since i have again some problems with the resources...
    I have some custom widget plugins that have pixmap properties.
    In design time and preview all works as it should.
    But at run time some pixmaps didn't show up while other pixmap properties did.
    After exemining the ui and the uic generated code I found out that the pixmaps I choose in designer (from a resource file) are simply not being saved when I save the form.
    So far I could not find an explanation for this, and was wondering if any of you might know what I might be doin to couse this?
    As I said, the strange thing about this, is that its not for all pixmap properties, just for some...
    This is the ui xml code where you can see a correct saved property:
    Qt Code:
    1. <property name="maskPixmap" stdset="0" >
    2. <pixmap resource="../sharpeye.qrc" >:/res/bt_zoom_plus1.png</pixmap>
    3. </property>
    To copy to clipboard, switch view to plain text mode 
    And here a broken saved property:
    Qt Code:
    1. <property name="firstStatePixmap" stdset="0" >
    2. <pixmap/>
    3. </property>
    To copy to clipboard, switch view to plain text mode 
    So no wonder the C++ generated code sets an empty QPixmap...

    Any idea what I might be doing wrong to couse this, or can it be a bug?

    Thanks.

Similar Threads

  1. Qt3 qprocess, executable exited?
    By triperzonak in forum Newbie
    Replies: 2
    Last Post: 22nd September 2008, 11: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.