×
Namespaces

Variants
Actions
(Difference between revisions)

Change font in Qt application

From Nokia Developer Wiki
Jump to: navigation, search
savaj (Talk | contribs)
(Savaj -)
hamishwillee (Talk | contribs)
m (Hamishwillee - Update ArticleMetaData. Remove pre-requisite (SDK assumed). Specific SDK version used should still be put in article metadata)
Line 1: Line 1:
 
[[Category:Qt]][[Category:UI]][[Category:Code Examples]]
 
[[Category:Qt]][[Category:UI]][[Category:Code Examples]]
 
{{ReviewerApproved|timestamp=20090921}}
 
{{ReviewerApproved|timestamp=20090921}}
 
 
{{ArticleMetaData
 
{{ArticleMetaData
|id=...
 
 
|platform=Symbian^1,Symbian^3, Meamo, MeeGo
 
|platform=Symbian^1,Symbian^3, Meamo, MeeGo
 
|devices=Nokia 5800 XpressMusic
 
|devices=Nokia 5800 XpressMusic
|category=Qt
+
|creationdate=20090612
|subcategory= UI
+
|creationdate=June 12, 2009
+
 
|keywords=Font
 
|keywords=Font
 
+
|sourcecode=[[Media:QtChangeFont.zip]]
|sourcecode= <!-- Link to example source code (e.g. [[Media:The Code Example ZIP.zip]]) -->
+
 
|installfile= <!-- Link to installation file (e.g. [[Media:The Installation File.sis]]) -->
 
|installfile= <!-- Link to installation file (e.g. [[Media:The Installation File.sis]]) -->
 
|sdk=<!-- SDK(s) built and tested against (e.g. [http://linktosdkdownload/ Nokia Qt SDK 1.1]) -->
 
|sdk=<!-- SDK(s) built and tested against (e.g. [http://linktosdkdownload/ Nokia Qt SDK 1.1]) -->
 
|devicecompatability=<!-- Compatible devices (e.g.: All* (must have GPS) ) -->
 
|devicecompatability=<!-- Compatible devices (e.g.: All* (must have GPS) ) -->
|signing=<!-- Empty or one of Self-Signed, DevCert, Manufacturer -->
+
|signing=Self-Signed
 
|capabilities=<!-- Capabilities required (e.g. Location, NetworkServices.) -->
 
|capabilities=<!-- Capabilities required (e.g. Location, NetworkServices.) -->
 
|author=[[User:Savaj]]
 
|author=[[User:Savaj]]
Line 25: Line 20:
  
 
This snippet can be '''self-signed'''.
 
This snippet can be '''self-signed'''.
 
==Preconditions==
 
 
* Install [[Qt SDK]]
 
  
 
==Headers required==
 
==Headers required==
Line 38: Line 29:
  
 
<code cpp>
 
<code cpp>
//specify a  new font.
+
//specify a  new font.
QFont newFont("Courier", 8, QFont::Bold, true);
+
QFont newFont("Courier", 8, QFont::Bold, true);
//set font of application
+
//set font of application
QApplication::setFont(newFont);
+
QApplication::setFont(newFont);
 
</code>
 
</code>
 
  
 
==Postconditions==
 
==Postconditions==

Revision as of 02:51, 26 October 2011

{{{width}}}
21 Sep
2009
Article Metadata
Code ExampleTested with
Devices(s): Nokia 5800 XpressMusic
Compatibility
Platform(s): Symbian^1,Symbian^3, Meamo, MeeGo
Symbian
Platform Security
Signing Required: Self-Signed
Article
Keywords: Font
Created: savaj (12 Jun 2009)
Last edited: hamishwillee (26 Oct 2011)

Contents

Overview

This code example shows how to change font of application an in Qt. This is done by setting the desired font QFont using QApplication::setFont().

This snippet can be self-signed.

Headers required

#include <QFont>

Source

//specify a  new font.
QFont newFont("Courier", 8, QFont::Bold, true);
//set font of application
QApplication::setFont(newFont);

Postconditions

The code snippet is expected to show font "Courier" on application.

Font Courier (Bold and Italic)

Font1.JPG

After changing font to Times
Font2.JPG


External links

Internal Links

Code Example

  • File:QtChangeFont.zip shows how you can change text from font Courier to font Times from the menu. The example is tested on Nokia 5800 XpressMusic.
527 page views in the last 30 days.
×