Results 1 to 3 of 3

Thread: Fill Screen with a single colour.

  1. #1

    Default Fill Screen with a single colour.

    I've viewed a lot of drawing examples online but I'm still struggling to work out the best way to simply fill screen with one colour in the simplest possible way. (Literally every pixel set one colour, no window bar, no more.)

    I'd like to use QPainter because that would give me a starting point to go on to do some drawing. However I'm wondering if using QSplashScreen might be a *very* quick way to simply fill the screen.

    Something like this?

    Qt Code:
    1. int main(int argc, char *argv[])
    2. {
    3. QApplication app(argc, argv);
    4. QPixmap pixmap(100, 100);
    5. pixmap.fill(Qt::white);
    6. QSplashScreen *splash = new QSplashScreen(pixmap);
    7. splash->setPixmap( pixmap );
    8. splash->show();
    9. return app.exec();
    10. }
    To copy to clipboard, switch view to plain text mode 

    Can someone suggest a better method or even better post some example code.

  2. #2
    Join Date
    Jul 2008
    Posts
    139
    Thanks
    9
    Thanked 18 Times in 15 Posts
    Qt products
    Qt/Embedded
    Platforms
    Unix/X11

    Default Re: Fill Screen with a single colour.

    Hi,
    I used this to get rid of the window bar.
    Qt Code:
    1. setFrameStyle(QFrame::NoFrame); // QFrame::Panel | QFrame::Raised
    2. setWindowFlags(Qt::FramelessWindowHint);
    To copy to clipboard, switch view to plain text mode 

    You may try to use QCoreApplication::setPalette
    I used the following for changing my background color. Set a pixmap or use a QColor for the Brush.

    Qt Code:
    1. QWSServer::setBackground(QBrush(pix)); // set default background color
    To copy to clipboard, switch view to plain text mode 

  3. #3
    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: Fill Screen with a single colour.

    Quote Originally Posted by TotalNovice View Post
    Can someone suggest a better method or even better post some example code.
    Qt Code:
    1. int main(int argc, char **argv){
    2. QApplication app(argc, argv);
    3. QPalette p = w.palette();
    4. p.setColor(QPalette::Window, Qt::blue);
    5. w.setPalette(p);
    6. w.setAutoFillBackground(true);
    7. w.showFullScreen();
    8. return w.exec();
    9. }
    To copy to clipboard, switch view to plain text mode 
    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.


Similar Threads

  1. Replies: 4
    Last Post: 2nd December 2010, 06:51
  2. Replies: 2
    Last Post: 11th June 2010, 07:23
  3. Window colour
    By phillip_Qt in forum Qt Programming
    Replies: 24
    Last Post: 28th February 2008, 06:25
  4. Same shape different colour
    By anafor2004 in forum Newbie
    Replies: 5
    Last Post: 11th February 2008, 10:02
  5. background colour
    By kw in forum Qt Programming
    Replies: 6
    Last Post: 11th April 2006, 00:44

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.