×
Namespaces

Variants
Actions
(Difference between revisions)

Archived:Changing QWidget background colour

From Nokia Developer Wiki
Jump to: navigation, search
tepaa (Talk | contribs)
(New page: {{CodeSnippet |id= |platform=Qt |devices=5800 XpressMusic |category=Qt for S60 |subcategory=UI |creationdate=March 27, 2009 |keywords=QPalette }} ==Overview== This code snippets shows h...)
 
mind_freak (Talk | contribs)
Line 21: Line 21:
 
* Check this link for installation guide: [http://pepper.troll.no/s60prereleases/doc/install-s60.html How to install the package]
 
* Check this link for installation guide: [http://pepper.troll.no/s60prereleases/doc/install-s60.html How to install the package]
  
 +
 +
== Main Function ==
 +
*Used to set the widget color
 +
 +
  p.setColor(QPalette::Background, Qt::black);
  
 
==Source==
 
==Source==
Line 37: Line 42:
 
</code>
 
</code>
  
 +
==Screenshot==
 +
More about [http://pepper.troll.no/s60prereleases/doc/qpalette.html QPalette]
 +
 +
[[Image:Pallets.JPG]]
 +
 +
 +
[[Image:P.JPG]]
 +
*Make the widget color RED
 +
 +
More about [http://pepper.troll.no/s60prereleases/doc/qpalette.html QPalette]
  
 
==Postconditions==
 
==Postconditions==

Revision as of 22:41, 27 March 2009

Article Metadata
Tested with
Devices(s): 5800 XpressMusic
Compatibility
Platform(s): Qt
Symbian
Article
Keywords: QPalette
Created: (27 Mar 2009)
Last edited: mind_freak (27 Mar 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);
}

Screenshot

More about QPalette

Pallets.JPG


P.JPG

  • Make the widget color RED

More about QPalette

Postconditions

QWidget background color is black.

228 page views in the last 30 days.
×