Results 1 to 4 of 4

Thread: my first qt application, everythings ok, but background image get nothing. help me!!!

  1. #1
    Join Date
    Dec 2011
    Posts
    2
    Qt products
    Qt4 Qt/Embedded
    Thanks
    2

    Unhappy my first qt application, everythings ok, but background image get nothing. help me!!!

    Qt Code:
    1. #include <QtGui>
    2.  
    3. int main(int argc, char** argv){
    4. QApplication apps(argc, argv);
    5. apps.setApplicationName("Application Demo");
    6.  
    7. QPalette palette;
    8. palette.setBrush(QPalette::Window, QBrush(QPixmap("demo.jpg")));
    9.  
    10. wnds.setAutoFillBackground(true);
    11. wnds.setWindowTitle("QMainWindow Demo");
    12. wnds.setWindowFlags(wnds.windowFlags() & ~Qt::WindowMinimizeButtonHint & Qt::FramelessWindowHint);
    13. wnds.setPalette(palette);
    14. wnds.statusBar()->showMessage("StatusBar Ready");
    15. wnds.resize(800,600); // pixmap.size()
    16. wnds.show(); // wnds.showMaximized();
    17.  
    18. return apps.exec();
    19. }
    To copy to clipboard, switch view to plain text mode 
    Last edited by Lykurg; 24th December 2011 at 17:14. Reason: missing [code] tags

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

    Default Re: my first qt application, everythings ok, but background image get nothing. help m

    Hi,

    what is
    Qt Code:
    1. qWarning() << p.load("demo.jpg");
    2. qWarning() << p.isNull();
    To copy to clipboard, switch view to plain text mode 
    telling you? I bet your path is wrong. As a solution use Qt's resource system to embed the image to your application or use a valid path...

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

    mackluo (24th December 2011)

  4. #3
    Join Date
    Oct 2007
    Location
    Lake Forest, CA, USA
    Posts
    132
    Qt products
    Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android
    Thanks
    10
    Thanked 27 Times in 22 Posts

    Default Re: my first qt application, everythings ok, but background image get nothing. help m

    Your code works, so check path to the image.
    Oleg Shparber

  5. The following user says thank you to Oleg for this useful post:

    mackluo (24th December 2011)

  6. #4
    Join Date
    Dec 2011
    Posts
    2
    Qt products
    Qt4 Qt/Embedded
    Thanks
    2

    Default Re: my first qt application, everythings ok, but background image get nothing. help m

    oh yes! qtWarning return QPixmap::load("demo.jpg") as false.
    thanks everybody, this is very helpful. i should use qt's resource next time.

Similar Threads

  1. Replies: 0
    Last Post: 5th April 2011, 14:36
  2. Replies: 1
    Last Post: 25th June 2010, 19:31
  3. Background image in an application
    By halvors in forum Qt Programming
    Replies: 1
    Last Post: 1st April 2010, 12:27
  4. No Background Image on Example
    By igor in forum Qt Programming
    Replies: 3
    Last Post: 19th January 2007, 13:41
  5. [QT4.1.1 XP] background image
    By incapacitant in forum Newbie
    Replies: 3
    Last Post: 1st March 2006, 14:02

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
  •  
Qt is a trademark of The Qt Company.