Namespaces
Variants
Actions
(Redirected from How to use QFontComboBox)

Archived:How to use QFontComboBox

Jump to: navigation, search
Archived.png
Archived: This article is archived because it is not considered relevant for third-party developers creating commercial solutions today. If you think this article is still relevant, let us know by adding the template {{ReviewForRemovalFromArchive|user=~~~~|write your reason here}}.

Qt Quick should be used for all UI development on mobile devices. The approach described in this article (based on QWidget) is deprecated.
Article Metadata

Tested with
Devices(s): S60 Emulator

Compatibility
Platform(s): Qt 4.5

Article
Keywords: QFont,QTextEdit,QFontComboBox
Created: valderind4 (20 Sep 2009)
Last edited: hamishwillee (11 Oct 2012)

Contents

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.


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

Fontcombo001.jpg

More about QFontComboBox

This page was last modified on 11 October 2012, at 04:14.
213 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