Archived:How to use QFontComboBox
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.
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
More about QFontComboBox



(no comments yet)