You Are Here:

Community: Wiki

This page was last modified on 31 October 2009, at 14:12.

How to use QFontComboBox in Qt for Symbian

From Forum Nokia Wiki

(Redirected from How to use QFontComboBox)


Reviewer Approved   



ID ... Creation date 28 March 2009
Platform S60 3rd Edition FP1, S60 3rd Edition FP2, S60 5th Edition Tested on devices S60 Emulator
Category Qt for S60 Subcategory Application


Keywords (APIs, classes, methods, functions): QFont,QTextEdit,QFontComboBox

Overview

The QFontComboBox widget is a combobox that lets the user select a font family.

The combobox is populated with an alphabetized list of font family names, such as Arial, Helvetica, and Times New Roman. Family names are displayed using the actual font when possible.

For fonts such as Symbol, where the name is not representable in the font itself, a sample of the font is displayed next to the family name.QFontComboBox

This exmaple makes the use of following classes

QFontComboBox

QFont

Preconditions

Various function

  • This property holds the filter for the combobox.
QFontComboBox *font=new QFontComboBox();
font->setFontFilter(QFontComboBox::NonScalableFonts);
  • This property holds the writing system that serves as a filter for the combobox.
font->setWritingSystem(QFontDatabase::Thaana);

Signal and Slots

QObject::connect(font,SIGNAL(currentFontChanged(QFont)),edit,SLOT(setCurrentFont(QFont)));

Source code

#include <QtGui/QApplication>
#include "fontcombo.h"
#include<QWidget>
#include<QVBoxLayout>
#include<QTextEdit>
#include<QFontComboBox>
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
QWidget *win=new QWidget();
QVBoxLayout *lay=new QVBoxLayout();
QTextEdit *edit=new QTextEdit();
QFontComboBox *font=new QFontComboBox();
QObject::connect(font,SIGNAL(currentFontChanged(QFont)),edit,SLOT(setCurrentFont(QFont));
lay->addWidget(font);
lay->addWidget(edit);
win->setLayout(lay);
win->setStyleSheet("* { background-color:rgb(199,147,88); padding: 7px ; color:rgb(255,255,255)}");
win->showMaximized();
return a.exec();
}

Screenshot

More about QFontComboBox

Image:Fontcombo001.jpg

More about QFontComboBox

Rate This

 
Bookmark this page: DeliciousDiggFacebookGoogleYahooStumbleUponRedditDiigoTechnocratiTwitter  Share this page Share this page Print this Page Print this page Invite a friend Invite a friend
京ICP备05048969号    Email Newsletters Press Terms & Conditions Privacy Policy Sitemap Contact Us © 2009 Nokia