Namespaces
Variants
Actions
Revision as of 12:53, 28 April 2009 by tepaa (Talk | contribs)

Archived:Changing QWidget background colour

Jump to: navigation, search
Article Metadata

Tested with
Devices(s): 5800 XpressMusic

Compatibility
Platform(s): Qt

Article
Keywords: QPalette
Created: (27 Mar 2009)
Last edited: tepaa (28 Apr 2009)

Contents

Overview

This code snippets shows how to change QWidget background color.

Note: In order to use this code, you need to have Qt for S60 installed on your platform.


Preconditions


Main Function

  • Used to set the widget color
 p.setColor(QPalette::Background, Qt::black);

Source

Change background color of the QWidget.

#include <QPalette>
 
QMyWidget::QMyWidget(QWidget *parent)
: QWidget(parent)
{
QPalette p(palette());
// Set background color to black
p.setColor(QPalette::Background, Qt::black);
setPalette(p);
}

See also

More about QPalette

Postconditions

QWidget background color is black.

628 page views in the last 30 days.
Nokia Developer aims to help you create apps and publish them so you can connect with users around the world.

京ICP备05048969号  © Copyright Nokia 2013 All rights reserved