Results 1 to 10 of 10

Thread: can't load picture

  1. #1
    Join Date
    Jul 2009
    Posts
    9
    Qt products
    Qt4
    Platforms
    Windows

    Default can't load picture

    i am a qt newer,i have already writtten the .qrc . why the picture not show?

    QPixmap map(":\images\robot1.png");
    ui.label->setPixmap(map);

    .qrc
    <!DOCTYPE RCC><RCC version="1.0">
    <qresource prefix="/">
    <file>images/robot1.png</file>
    </qresource>
    </RCC>

  2. #2
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Wiki edits
    5

    Default Re: can't load picture

    Did you use Q_INIT_RESOURCE? And use slashes instead of back slashes.

  3. #3
    Join Date
    Dec 2006
    Posts
    849
    Thanks
    6
    Thanked 163 Times in 151 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: can't load picture

    use "/" as directory separator; if you insist on "\" you must at least escape the "\" properly

  4. #4
    Join Date
    Jul 2009
    Posts
    9
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: can't load picture

    QPixmap map(":/images/robot1.png");
    it did not work,how to use Q_INIT_RESOURCE,
    i added code in main(),but

    QApplication a(argc, argv);
    Q_INIT_RESOURCE(a);

    there is a error "1>main.obj : error LNK2019: unresolved external symbol "int __cdecl qInitResources_a(void)" (?qInitResources_a@@YAHXZ) referenced in function _main"

  5. #5
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Wiki edits
    5

    Default Re: can't load picture

    Quote Originally Posted by aoo7wangyan View Post
    ,how to use Q_INIT_RESOURCE
    This is all described in the docs. Please read them!

  6. #6
    Join Date
    Jul 2009
    Posts
    9
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: can't load picture

    i write code as doc,added Q_INIT_RESOURCE(a),but it did not work.

    int main(int argc, char *argv[])
    {
    ....
    QApplication a(argc, argv);
    Q_INIT_RESOURCE(a);
    ....
    }

  7. #7
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Wiki edits
    5

    Default Re: can't load picture

    what's the full name of our qrc file. Have you altered you pro file?

  8. #8
    Join Date
    Jul 2009
    Posts
    9
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: can't load picture

    My enviroment is msvc in windows, how to alter my file?

  9. #9
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Wiki edits
    5

    Default Re: can't load picture

    Quote Originally Posted by aoo7wangyan View Post
    My enviroment is msvc in windows
    I have supposed that, but what I have meant is, what file name has you qrc file. And how to alter your pro file, you can read in the docs under the topic "The Qt Resource System" (-> RESOURCES)...

  10. #10
    Join Date
    Jul 2009
    Posts
    9
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: can't load picture

    thank you ,i solve it .it need change the .qrc file's properties in VS solution explorer.

    command line:C:\Qt\4.5-msvc2008\bin\rcc.exe -name teach teach.qrc -o qrc_teach.cpp
    description:RCC 222.qrc
    outputs:qrc_teach.cpp
    additional dependencies:C:\Qt\4.5-msvc2008\bin\rcc.exe;teach.qrc

Similar Threads

  1. HELP! QtLibrary.. Load library failed!!
    By Cantora in forum Newbie
    Replies: 1
    Last Post: 10th June 2009, 10:18
  2. Print RichText and a scaled Picture
    By kray in forum Qt Programming
    Replies: 1
    Last Post: 29th December 2008, 20:56
  3. Program not compiling on Fresh install of Leopard
    By dvmorris in forum Qt Programming
    Replies: 1
    Last Post: 22nd November 2007, 10:22
  4. wait copy picture then show it
    By raphaelf in forum Newbie
    Replies: 6
    Last Post: 5th November 2006, 12:09

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.