[release/qrc_ICON.cpp] Error 1:File not found



  • here is my code

    ICON.qrc
    @<!DOCTYPE RCC><RCC version="1.0">
    <qresource>
    <file>images/accept.png</file>
    </qresource>
    </RCC>
    @

    main.cpp
    @#include <QApplication>
    #include<QIcon>
    #include<QPushButton>
    #include<QAction>

    int main( int argc, char** argv )
    {
    QApplication app( argc, argv );

    QIcon w("/images/accept.png");
    QPushButton a;
    QAction *b=new QAction(w,QString("Icon"),0);

    a.addAction(b);
    a.show();

    return app.exec();
    }@

    empty2.pro
    @SOURCES +=
    main.cpp
    buttondialog.cpp

    HEADERS +=
    buttondialog.h

    RESOURCES +=
    ICON.qrc@

    When I build the project,Qt Creator shows" [release/qrc_ICON.cpp] Error 1:File not found".
    I don't know why.



  • you forget the colon ":"
    QIcon w(":/images/accept.png");
    if you use resource, you should use colon before the path string



  • [quote author="broadpeak" date="1347262204"]you forget the colon ":"
    QIcon w(":/images/accept.png");
    if you use resource, you should use colon before the path string[/quote]

    Thank you.I have correct the code,but Qt Creator still shows the same error.



  • In qrc file you don't have prefix like this: <qresource prefix="/">



  • [quote author="broadpeak" date="1347285954"]In qrc file you don't have prefix like this: <qresource prefix="/"> [/quote]
    Thank you.I have correct the code again,but Qt Creator still shows the same error.



  • This is works for me:

    @
    #include <QApplication>
    #include <QIcon>
    #include <QPushButton>
    #include <QToolButton>
    #include <QAction>

    int main( int argc, char** argv )
    {
    QApplication app( argc, argv );

    QPushButton a;
    QIcon w(":/images/accept.png");
    QAction* b=new QAction( QString("Icon"), 0);
    a.setIcon(w);
    
    a.addAction(b);
    a.show();
    
    return app.exec();
    

    }
    @

    @
    <RCC>
    <qresource prefix="/">
    <file>images/accept.png</file>
    </qresource>
    </RCC>
    @

    @
    SOURCES +=
    main.cpp
    buttondialog.cpp

    HEADERS +=
    buttondialog.h
    buttondialog.h

    RESOURCES += icon.qrc
    @

    Pay attention when you paste this code, because the quotation marks (") can be wrong!



  • Thank you very much. Now I find that if I open the qrc file with Resource Editor,it will works well.The strange thing is if I use Plain Text Editor to open qrc file and paste the code,it will show error "[release/qrc_ICON.cpp] Error 1:File not found".



  • I want to konw your solution about this problem, could you tell me?

    [quote author="nimingzhe2008" date="1347289193"]Thank you very much. Now I find that if I open the qrc file with Resource Editor,it will works well.The strange thing is if I use Plain Text Editor to open qrc file and paste the code,it will show error "[release/qrc_ICON.cpp] Error 1:File not found".[/quote]



  • [quote author="Hughen" date="1350390978"]I want to konw your solution about this problem, could you tell me?

    [/quote]
    sorry,no new solution.



  • I had the same error, except without the "file not found" part of the message. I opened the qrc file in the resource editor and noticed one filename was in red. This meant that the file cannot be found. Removed it from the qrc and now it works.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.