Results 1 to 5 of 5

Thread: Changing QMainWindows backgroundcolor

  1. #1
    Join Date
    Sep 2011
    Location
    Mannheim, Germany
    Posts
    22
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Changing QMainWindows backgroundcolor

    Hi,

    I want to change the backgroundcolor of QMainWindow.
    setStyleSheet("QMainWindow {background-color: #000000}"); changes the background color of menubar, but not of the centralwidget.
    QMainWindow::centralWidget(); returns a NULL-Pointer.

    Is there a special stylesheet tag for the empty centralwidget area?

  2. #2
    Join Date
    May 2012
    Location
    Bangalore, India
    Posts
    271
    Thanks
    29
    Thanked 50 Times in 47 Posts
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: Changing QMainWindows backgroundcolor

    Qt Code:
    1. MainWindow->setStyleSheet("background-color: rgb(0, 0, 0);");
    To copy to clipboard, switch view to plain text mode 
    Heavy Metal Rules. For those about to rock, we salute you.
    HIT THANKS IF I HELPED.

  3. #3
    Join Date
    Sep 2011
    Location
    Mannheim, Germany
    Posts
    22
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Changing QMainWindows backgroundcolor

    Quote Originally Posted by sonulohani View Post
    Qt Code:
    1. MainWindow->setStyleSheet("background-color: rgb(0, 0, 0);");
    To copy to clipboard, switch view to plain text mode 
    It does not affect the central widget. It is still gray :-(

  4. #4
    Join Date
    Apr 2011
    Location
    Gurgaon
    Posts
    32
    Thanks
    6
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Changing QMainWindows backgroundcolor

    Try to use setpallete()


    Added after 14 minutes:


    Try to use setpallete()
    Last edited by anupam; 9th October 2012 at 12:32.

  5. #5
    Join Date
    Sep 2011
    Location
    Mannheim, Germany
    Posts
    22
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Changing QMainWindows backgroundcolor

    The solution is to set a centralwidget and change its background:

    setCentralWidget(mMdiArea);
    QBrush backBrush;
    backBrush.setTexture(QPixmap(":/background.png"));
    mMdiArea->setBackground(backBrush);

Similar Threads

  1. Dragging QDockWidgets between QMainWindows
    By FelixB in forum Newbie
    Replies: 3
    Last Post: 14th October 2011, 07:37
  2. shared QUnstackStack among several QMainWindows ?
    By umanga in forum Qt Programming
    Replies: 2
    Last Post: 11th November 2010, 06:58
  3. How to change between QMainWindows???
    By webquinty in forum Newbie
    Replies: 3
    Last Post: 16th October 2009, 10:46
  4. HeaderView BackgroundColor
    By dragon in forum Qt Programming
    Replies: 10
    Last Post: 9th July 2008, 19:22
  5. QTreeWidget backgroundcolor
    By vmferreira in forum Qt Programming
    Replies: 5
    Last Post: 9th August 2006, 20:21

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.