Change font in Qt application
hamishwillee
(Talk | contribs) m (Hamishwillee - Bot change of template (Template:CodeSnippet) - now using Template:ArticleMetaData) |
hamishwillee
(Talk | contribs) m (Text replace - "<code cpp>" to "<code cpp-qt>") |
||
| (12 intermediate revisions by 2 users not shown) | |||
| Line 1: | Line 1: | ||
| − | [[Category:Qt]][[Category:UI]] | + | [[Category:Qt]][[Category:UI]][[Category:Code Examples]][[Category:MeeGo Harmattan]][[Category:Symbian]][[Category:Qt C++ UI]] |
| − | {{ | + | {{Abstract|This code example shows how to change font of a Qt (C++) application. This is done by setting the desired font {{Qapiname|QFont}} using {{Qapiname|QApplication::setFont()}}.}} |
| − | {{ArticleMetaData | + | {{ArticleMetaData <!-- v1.2 --> |
| − | + | |sourcecode= [[Media:QtChangeFont.zip]] | |
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | |sourcecode= | + | |
|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]) --> | + | |devices= Nokia 5800 XpressMusic |
| − | |devicecompatability=<!-- Compatible devices (e.g.: All* (must have GPS) ) --> | + | |sdk= <!-- SDK(s) built and tested against (e.g. [http://linktosdkdownload/ Nokia Qt SDK 1.1]) --> |
| − | | | + | |platform= Symbian^1,Symbian^3, Meamo, MeeGo |
| − | |capabilities=<!-- Capabilities required (e.g. Location, NetworkServices. | + | |devicecompatability= <!-- Compatible devices (e.g.: All* (must have GPS) ) --> |
| − | |author=[[User:Savaj]] | + | |dependencies= <!-- Any other/external dependencies e.g.: Google Maps Api v1.0 --> |
| + | |signing= Self-Signed | ||
| + | |capabilities= <!-- Capabilities required by the article/code example (e.g. Location, NetworkServices. --> | ||
| + | |keywords= Font | ||
| + | |language= <!-- Language category code for non-English topics - e.g. Lang-Chinese --> | ||
| + | |translated-by= <!-- [[User:XXXX]] --> | ||
| + | |translated-from-title= <!-- Title only --> | ||
| + | |translated-from-id= <!-- Id of translated revision --> | ||
| + | |review-by= <!-- After re-review: [[User:username]] --> | ||
| + | |review-timestamp= <!-- After re-review: YYYYMMDD --> | ||
| + | |update-by= <!-- After significant update: [[User:username]]--> | ||
| + | |update-timestamp= <!-- After significant update: YYYYMMDD --> | ||
| + | |creationdate= 20090612 | ||
| + | |author= [[User:Savaj]] | ||
}} | }} | ||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
==Headers required== | ==Headers required== | ||
| − | <code cpp> | + | <code cpp-qt> |
#include <QFont> | #include <QFont> | ||
</code> | </code> | ||
| Line 37: | Line 32: | ||
==Source== | ==Source== | ||
| − | <code cpp> | + | <code cpp-qt> |
| − | + | //specify a new font. | |
| − | + | QFont newFont("Courier", 8, QFont::Bold, true); | |
| − | + | //set font of application | |
| − | + | QApplication::setFont(newFont); | |
</code> | </code> | ||
| − | |||
==Postconditions== | ==Postconditions== | ||
| − | The code snippet is expected to show font "Courier" on application. | + | The code snippet is expected to show font "Courier" on application. |
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| + | <gallery widths="300px" heights="400px"> | ||
| + | File:Font1.JPG|Font Courier (Bold and Italic) | ||
| + | File:Font2.JPG|After changing font to Times | ||
| + | </gallery> | ||
| − | == | + | ==Further links== |
| − | * | + | * {{Qapiname|QFont}} |
| − | + | ||
| − | + | ||
* [[How to use QFontComboBox]] | * [[How to use QFontComboBox]] | ||
| Line 66: | Line 55: | ||
* [[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. | * [[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. | ||
| − | + | <!-- Translation --> [[pt:Archived:Como modificar a fonte de aplicações, em Qt]] | |
| − | + | ||
| − | + | ||
| − | + | ||
Latest revision as of 04:13, 11 October 2012
This code example shows how to change font of a Qt (C++) application. This is done by setting the desired font QFont using QApplication::setFont().
Article Metadata
Code Example
Source file: Media:QtChangeFont.zip
Tested with
Devices(s): Nokia 5800 XpressMusic
Compatibility
Platform(s): Symbian^1,Symbian^3, Meamo, MeeGo
Platform Security
Signing Required: Self-Signed
Article
Keywords: Font
Created: savaj
(12 Jun 2009)
Last edited: hamishwillee
(11 Oct 2012)
Contents |
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.
Further 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.

