Results 1 to 2 of 2

Thread: problem with the back ground image

  1. #1
    Join Date
    Feb 2006
    Posts
    42
    Thanks
    1
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11

    Post problem with the back ground image

    I have problem adding background image to window. Here is the code I have used to draw back ground image for my sample,
    MainWindow::MainWindow()
    {


    first= new QWidget;
    second= new QWidget;
    third= new QWidget;

    QHBoxLayout *mainLayout= new QHBoxLayout;
    mainLayout->addWidget(first);
    mainLayout->addWidget(second);
    mainLayout->addWidget(third);

    //code to add background image
    QPalette palette;
    QPixmap pixmap = QPixmap("images/first2.bmp");
    palette.setBrush((this)->backgroundRole(), QBrush(pixmap));
    (this)->setPalette(palette);

    setMinimumSize(400, 200);
    resize(480, 320);
    }

    Background image comes up but it covers the whole window by tailing one and half times. How to set back ground image so that one instance of image covers the whole window?

    Thanks in advance,
    Seema Rao

  2. #2
    Join Date
    Jan 2006
    Location
    Mountain View, CA
    Posts
    279
    Thanked 42 Times in 37 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: problem with the back ground image

    Resize the window to the size of the image.
    Save yourself some pain. Learn C++ before learning Qt.

Similar Threads

  1. QTextDocument Image resource problem
    By patrik08 in forum Qt Programming
    Replies: 1
    Last Post: 16th August 2007, 16:28
  2. QStackedWidget fill Postscript image And scroll problem
    By patrik08 in forum Qt Programming
    Replies: 11
    Last Post: 22nd April 2007, 10:30
  3. Problem getting an image from a web server
    By probine in forum Qt Programming
    Replies: 3
    Last Post: 13th January 2007, 00:05
  4. Transfer image problem
    By probine in forum Qt Programming
    Replies: 7
    Last Post: 4th May 2006, 11:24
  5. problem with image colections
    By zlatko in forum Qt Programming
    Replies: 1
    Last Post: 6th February 2006, 14:43

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.