Results 1 to 2 of 2

Thread: how to make the background iamge scale to fullscreen?

  1. #1

    Default how to make the background iamge scale to fullscreen?

    class settingwindow : public QGraphicsView
    ...

    settingwindow::settingwindow( QWidget * parent) : QGraphicsView(parent)
    {
    setWindowState ( Qt::WindowFullScreen );
    QSize widgetSize = QSize(); //seems that QSize() return (-1,-1)
    QPixmap pixmap;
    pixmap.load("C:/Users/cherrson/qt_workspace/first/setting_1.JPG");
    QPixmap scaledPixmap = pixmap.scaled(widgetSize, Qt::IgnoreAspectRatio);
    setBackgroundBrush(scaledPixmap );
    scene = new QGraphicsScene;
    }

    In the main function, I create the settingwindow, and then call:
    setting->showFullScreen();

    But the background image is not show full screen, why & how?


    before I call showFullScreen(), I do not know the size.
    I also implement in resizeEvent , but size still (-1, -1)

    void settingwindow::resizeEvent ( QResizeEvent * event )
    {
    QSize widgetSize = QSize(); //still (-1,-1)
    QPixmap pixmap;
    pixmap.load("C:/Users/cherrson/qt_workspace/first/setting_1.JPG");
    QPixmap scaledPixmap = pixmap.scaled(widgetSize, Qt::IgnoreAspectRatio);
    setBackgroundBrush(scaledPixmap);
    }

    does not work too.

  2. #2

    Default Re: how to make the background iamge scale to fullscreen?

    resolved, change QSize() to size()

Similar Threads

  1. How to make a label be on the background?
    By Bong.Da.City in forum Newbie
    Replies: 3
    Last Post: 6th September 2010, 11:37
  2. How to make table headers with custom background?
    By kremuwa in forum Qt Programming
    Replies: 1
    Last Post: 14th March 2010, 16:51
  3. How to make my app to play background music
    By HelloDan in forum Qt Programming
    Replies: 3
    Last Post: 8th April 2009, 09:17
  4. make background invisible
    By punit.doshi.85 in forum Qt Programming
    Replies: 1
    Last Post: 1st October 2008, 10:48
  5. Replies: 13
    Last Post: 12th June 2008, 13:23

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.