Results 1 to 4 of 4

Thread: static compiled app, does not load image at runtime

  1. #1
    Join Date
    Nov 2007
    Posts
    291
    Thanks
    85
    Thanked 1 Time in 1 Post

    Default static compiled app, does not load image at runtime

    hi
    i have compiled an application statically and it has to set its background with image which is present in the file system.

    this is done like this

    Qt Code:
    1. QPalette palette;
    2. QPixmap pixmap = QPixmap("./icon/slide1.jpg");
    3. palette.setBrush((this)->backgroundRole(), QBrush(pixmap));
    4. (this)->setPalette(palette);
    To copy to clipboard, switch view to plain text mode 

    but it does not work if the program is compiled statically.

    but the same program compiled dynamically (using dynamic libraries) works.

    i am sure that there is no problem with path in which images are present.

    do compiling statically requires any modification.
    Last edited by babu198649; 6th March 2008 at 12:29. Reason: misspelled

  2. #2
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: staic compiled app, does not load image at runtime

    J-P Nurmi

  3. The following user says thank you to jpn for this useful post:

    babu198649 (6th March 2008)

  4. #3
    Join Date
    Nov 2007
    Posts
    291
    Thanks
    85
    Thanked 1 Time in 1 Post

    Default Re: staic compiled app, does not load image at runtime

    thanks jpn
    i have read in other threads that creating objects in stack(like QWidget w) causes crash. but some of the classes such as QPixmap ,QPalette ,et.c , even if they are created on the stack does not crash ,why.

  5. #4
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: staic compiled app, does not load image at runtime

    Quote Originally Posted by babu198649 View Post
    i have read in other threads that creating objects in stack(like QWidget w) causes crash. but some of the classes such as QPixmap ,QPalette ,et.c , even if they are created on the stack does not crash ,why.
    It's not that straight-forward at all. It's perfectly valid to allocate for example the main window in main() and modal dialogs on the stack. Why? Both are QWidgets.

    QObjects organize themselves in object trees. A parent takes ownership of its children and automatically deletes them when the parent is deleted. This would cause problems if children were allocated on the stack because they would (depending on the allocation order) end up being deleted twice; 1) by their parent and 2) by normal C++ rules when going out of scope. However, neither QPixmap, QPalette nor other implicitly shared classes are QObjects.
    J-P Nurmi

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

    babu198649 (6th March 2008)

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.