Results 1 to 11 of 11

Thread: plz help

  1. #1
    Join Date
    Jul 2010
    Posts
    50
    Thanks
    7
    Platforms
    Windows

    Default plz help

    I want to know how to display an image simply on a window i.e. how to just open a picture stored in the images folder in Qt? Plz give me the code to be added into the main() program.
    Last edited by wysota; 27th July 2010 at 13:28.

  2. #2
    Join Date
    Jan 2006
    Location
    Belgium
    Posts
    1,938
    Thanked 268 Times in 268 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Wiki edits
    20

  3. #3
    Join Date
    Jul 2010
    Posts
    53
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: plz help

    QLabel label;
    label.setPixmap(QPixmap("imagename"));

  4. #4
    Join Date
    Jul 2010
    Posts
    50
    Thanks
    7
    Platforms
    Windows

    Default Re: plz help

    so I'll have to do QLabel::setPicture ( ":/images/transparent.png")???
    There's one more problem. even when I run a basic code with the .qrc file and a folder "images" in the "new" folder in "bin", it shows "fatal error: can't open 'debug/new.exe' "........... I am showing the code below:

    //new.cpp
    #include <QApplication>
    int main(int argc,char *argv[])
    {
    QApplication app(argc,argv);
    return app.exec();
    }


    //new.qrc
    <RCC>
    <qresource>
    <file>images/transparent.png</file>
    </qresource>
    </RCC>

    //The contents of the new.pro file are:

    TEMPLATE = app
    TARGET =
    DEPENDPATH += . tmp\rcc\debug_shared
    INCLUDEPATH += .

    # Input
    SOURCES += new.cpp
    RESOURCES += new.qrc


    What is the error in this???

  5. #5
    Join Date
    Jul 2010
    Posts
    50
    Thanks
    7
    Platforms
    Windows

    Default Re: plz help

    Thanks a lot,but ,there's one more problem. even when I run a basic code with the .qrc file and a folder "images" in the "new" folder in "bin", it shows "fatal error: can't open 'debug/new.exe' "........... I am showing the code below:

    //new.cpp
    #include <QApplication>
    int main(int argc,char *argv[])
    {
    QApplication app(argc,argv);
    return app.exec();
    }


    //new.qrc
    <RCC>
    <qresource>
    <file>images/transparent.png</file>
    </qresource>
    </RCC>

    //The contents of the new.pro file are:

    TEMPLATE = app
    TARGET =
    DEPENDPATH += . tmp\rcc\debug_shared
    INCLUDEPATH += .

    # Input
    SOURCES += new.cpp
    RESOURCES += new.qrc


    What is the error in this???

  6. #6
    Join Date
    Sep 2009
    Location
    UK
    Posts
    2,447
    Thanks
    6
    Thanked 348 Times in 333 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: plz help

    First thing: Does the directory actually exist?

  7. #7
    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: plz help

    Quote Originally Posted by qt_user View Post
    it shows "fatal error: can't open 'debug/new.exe'
    You probably have another instance of the application running and the compiler can't overwrite the executable.
    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.


  8. #8
    Join Date
    Jul 2010
    Posts
    50
    Thanks
    7
    Platforms
    Windows

    Default Re: plz help

    Quote Originally Posted by wysota View Post
    You probably have another instance of the application running and the compiler can't overwrite the executable.
    I also thought on the same lines as you but......I could not find the existence of another instance in the processes in the task manager. How should I close that instance(other than restarting the computer-which I have not tried yet)

  9. #9
    Join Date
    Jul 2010
    Posts
    50
    Thanks
    7
    Platforms
    Windows

    Default Re: plz help

    Quote Originally Posted by fatjuicymole View Post
    First thing: Does the directory actually exist?
    ya the directory exists...........(did I not get what u intended to say???)

  10. #10
    Join Date
    Sep 2009
    Location
    UK
    Posts
    2,447
    Thanks
    6
    Thanked 348 Times in 333 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: plz help

    Whats in the debug folder at the moment?

  11. #11
    Join Date
    Jul 2010
    Posts
    50
    Thanks
    7
    Platforms
    Windows

    Default Re: plz help

    It is all clear........ "MasterOfZen" was right.......thanx a lot 2 u guys

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.