本文整理汇总了C++中QFontDatabase::standardSizes方法的典型用法代码示例。如果您正苦于以下问题:C++ QFontDatabase::standardSizes方法的具体用法?C++ QFontDatabase::standardSizes怎么用?C++ QFontDatabase::standardSizes使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QFontDatabase
的用法示例。
在下文中一共展示了QFontDatabase::standardSizes方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: fontChanged
void ThemeDialog::fontChanged()
{
QFontDatabase db;
QFont font = m_font_names->currentFont();
QList<int> font_sizes = db.smoothSizes(font.family(), QString());
if (font_sizes.isEmpty()) {
font_sizes = db.standardSizes();
}
qreal font_size = m_font_sizes->currentText().toDouble();
if (font_size < 0.1) {
font_size = std::lround(m_theme.textFont().pointSizeF() * 10.0) * 0.1;
}
m_font_sizes->blockSignals(true);
m_font_sizes->clear();
int index = 0;
for (int i = 0; i < font_sizes.count(); ++i) {
int size = font_sizes.at(i);
if (size <= font_size) {
index = i;
}
m_font_sizes->addItem(QString::number(size));
}
m_font_sizes->setCurrentIndex(index);
m_font_sizes->setEditText(QString::number(font_size));
m_font_sizes->setValidator(new QDoubleValidator(font_sizes.first(), font_sizes.last(), 1, m_font_sizes));
m_font_sizes->blockSignals(false);
}
示例2: slotChangeFontSize
void PQTextEditor::slotChangeFontSize(int index)
{
QFontDatabase db;
int fontSize = db.standardSizes().at(index);
QTextCharFormat format;
format.setFontPointSize(fontSize);
}
示例3: format
void FontSizeAction::Private::init()
{
q->setEditable( true );
QFontDatabase fontDB;
const QList<int> sizes = fontDB.standardSizes();
QStringList lst;
for ( QList<int>::ConstIterator it = sizes.begin(); it != sizes.end(); ++it ) {
lst.append( format(*it) );
}
q->setItems( lst );
}
示例4: __updateFontSize
void PreferenceDialog::__updateFontSize(const QFont& font)
{
QFontDatabase fontdatabase;
QList<int> sizeList = fontdatabase.smoothSizes(font.family(), "");
if (sizeList.empty()) sizeList = fontdatabase.pointSizes(font.family(), "");
if (sizeList.empty()) sizeList = fontdatabase.standardSizes();
if (!sizeList.contains(font.pointSize())) sizeList.append(font.pointSize());
fontSize->clear();
for (int size : sizeList) fontSize->addItem(QString::number(size), size);
fontSize->setCurrentIndex(sizeList.indexOf(fontFamilly->currentFont().pointSize()));
}
示例5: KComboBox
FontSizeCombo::FontSizeCombo(bool rw, bool withDefault, QWidget *parent)
: KComboBox(rw, parent), m_withDefault(withDefault)
{
if (m_withDefault)
addItem(i18n("(Default)"));
QFontDatabase fontDB;
QList<int> sizes = fontDB.standardSizes();
for (QList<int>::Iterator it = sizes.begin(); it != sizes.end(); ++it)
addItem(QString::number(*it));
// connect( this, SIGNAL(acivated(const QString&)), this, SLOT(textChangedInCombo(const QString&)) );
connect(this, SIGNAL(editTextChanged(const QString&)), this, SLOT(textChangedInCombo(const QString&)));
// TODO: 01617 void KFontSizeAction::setFontSize( int size )
}
示例6: setupTextActions
void TextEdit::setupTextActions()
{
QToolBar *tb = new QToolBar( this );
QPopupMenu *menu = new QPopupMenu( this );
menuBar()->insertItem( tr( "For&mat" ), menu );
comboStyle = new QComboBox( FALSE, tb );
comboStyle->insertItem( tr("Standard") );
comboStyle->insertItem( tr("Bullet List (Disc)") );
comboStyle->insertItem( tr("Bullet List (Circle)") );
comboStyle->insertItem( tr("Bullet List (Square)") );
comboStyle->insertItem( tr("Ordered List (Decimal)") );
comboStyle->insertItem( tr("Ordered List (Alpha lower)") );
comboStyle->insertItem( tr("Ordered List (Alpha upper)") );
connect( comboStyle, SIGNAL( activated( int ) ),
this, SLOT( textStyle( int ) ) );
comboFont = new QComboBox( TRUE, tb );
QFontDatabase db;
comboFont->insertStringList( db.families() );
connect( comboFont, SIGNAL( activated( const QString & ) ),
this, SLOT( textFamily( const QString & ) ) );
comboFont->lineEdit()->setText( QApplication::font().family() );
comboSize = new QComboBox( TRUE, tb );
QValueList<int> sizes = db.standardSizes();
QValueList<int>::Iterator it = sizes.begin();
for ( ; it != sizes.end(); ++it )
comboSize->insertItem( QString::number( *it ) );
connect( comboSize, SIGNAL( activated( const QString & ) ),
this, SLOT( textSize( const QString & ) ) );
comboSize->lineEdit()->setText( QString::number( QApplication::font().pointSize() ) );
actionTextBold = new QAction( tr( "Bold" ), QPixmap( "textdrawing/textbold.png" ), tr( "&Bold" ), CTRL + Key_B, this, "textBold" );
connect( actionTextBold, SIGNAL( activated() ), this, SLOT( textBold() ) );
actionTextBold->addTo( tb );
actionTextBold->addTo( menu );
actionTextBold->setToggleAction( TRUE );
actionTextItalic = new QAction( tr( "Italic" ), QPixmap( "textdrawing/textitalic.png" ), tr( "&Italic" ), CTRL + Key_I, this, "textItalic" );
connect( actionTextItalic, SIGNAL( activated() ), this, SLOT( textItalic() ) );
actionTextItalic->addTo( tb );
actionTextItalic->addTo( menu );
actionTextItalic->setToggleAction( TRUE );
actionTextUnderline = new QAction( tr( "Underline" ), QPixmap( "textdrawing/textunderline.png" ), tr( "&Underline" ), CTRL + Key_U, this, "textUnderline" );
connect( actionTextUnderline, SIGNAL( activated() ), this, SLOT( textUnderline() ) );
actionTextUnderline->addTo( tb );
actionTextUnderline->addTo( menu );
actionTextUnderline->setToggleAction( TRUE );
menu->insertSeparator();
QActionGroup *grp = new QActionGroup( this );
grp->setExclusive( TRUE );
connect( grp, SIGNAL( selected( QAction* ) ), this, SLOT( textAlign( QAction* ) ) );
actionAlignLeft = new QAction( tr( "Left" ), QPixmap( "textdrawing/textleft.png" ), tr( "&Left" ), CTRL + Key_L, grp, "textLeft" );
actionAlignLeft->addTo( tb );
actionAlignLeft->addTo( menu );
actionAlignLeft->setToggleAction( TRUE );
actionAlignCenter = new QAction( tr( "Center" ), QPixmap( "textdrawing/textcenter.png" ), tr( "C&enter" ), CTRL + Key_M, grp, "textCenter" );
actionAlignCenter->addTo( tb );
actionAlignCenter->addTo( menu );
actionAlignCenter->setToggleAction( TRUE );
actionAlignRight = new QAction( tr( "Right" ), QPixmap( "textdrawing/textright.png" ), tr( "&Right" ), CTRL + Key_R, grp, "textRight" );
actionAlignRight->addTo( tb );
actionAlignRight->addTo( menu );
actionAlignRight->setToggleAction( TRUE );
actionAlignJustify = new QAction( tr( "Justify" ), QPixmap( "textdrawing/textjustify.png" ), tr( "&Justify" ), CTRL + Key_J, grp, "textjustify" );
actionAlignJustify->addTo( tb );
actionAlignJustify->addTo( menu );
actionAlignJustify->setToggleAction( TRUE );
menu->insertSeparator();
QPixmap pix( 16, 16 );
pix.fill( black );
actionTextColor = new QAction( tr( "Color" ), pix, tr( "&Color..." ), 0, this, "textColor" );
connect( actionTextColor, SIGNAL( activated() ), this, SLOT( textColor() ) );
actionTextColor->addTo( tb );
actionTextColor->addTo( menu );
}
示例7: setupTextActions
void TextEdit::setupTextActions()
{
QToolBar *tb = new QToolBar( this );
tb->setLabel( "Format Actions" );
QPopupMenu *menu = new QPopupMenu( this );
menuBar()->insertItem( tr( "F&ormat" ), menu );
comboFont = new QComboBox( TRUE, tb );
QFontDatabase db;
comboFont->insertStringList( db.families() );
connect( comboFont, SIGNAL( activated( const QString & ) ),
this, SLOT( textFamily( const QString & ) ) );
comboFont->lineEdit()->setText( QApplication::font().family() );
comboSize = new QComboBox( TRUE, tb );
QValueList<int> sizes = db.standardSizes();
QValueList<int>::Iterator it = sizes.begin();
for ( ; it != sizes.end(); ++it )
comboSize->insertItem( QString::number( *it ) );
connect( comboSize, SIGNAL( activated( const QString & ) ),
this, SLOT( textSize( const QString & ) ) );
comboSize->lineEdit()->setText( QString::number( QApplication::font().pointSize() ) );
actionTextBold = new QAction( QPixmap::fromMimeSource( "textbold.xpm" ), tr( "&Bold" ), CTRL + Key_B, this, "textBold" );
connect( actionTextBold, SIGNAL( activated() ), this, SLOT( textBold() ) );
actionTextBold->addTo( tb );
actionTextBold->addTo( menu );
actionTextBold->setToggleAction( TRUE );
actionTextItalic = new QAction( QPixmap::fromMimeSource( "textitalic.xpm" ), tr( "&Italic" ), CTRL + Key_I, this, "textItalic" );
connect( actionTextItalic, SIGNAL( activated() ), this, SLOT( textItalic() ) );
actionTextItalic->addTo( tb );
actionTextItalic->addTo( menu );
actionTextItalic->setToggleAction( TRUE );
actionTextUnderline = new QAction( QPixmap::fromMimeSource( "textunder.xpm" ), tr( "&Underline" ), CTRL + Key_U, this, "textUnderline" );
connect( actionTextUnderline, SIGNAL( activated() ), this, SLOT( textUnderline() ) );
actionTextUnderline->addTo( tb );
actionTextUnderline->addTo( menu );
actionTextUnderline->setToggleAction( TRUE );
menu->insertSeparator();
QActionGroup *grp = new QActionGroup( this );
connect( grp, SIGNAL( selected( QAction* ) ), this, SLOT( textAlign( QAction* ) ) );
actionAlignLeft = new QAction( QPixmap::fromMimeSource( "textleft.xpm" ), tr( "&Left" ), CTRL + Key_L, grp, "textLeft" );
actionAlignLeft->setToggleAction( TRUE );
actionAlignCenter = new QAction( QPixmap::fromMimeSource( "textcenter.xpm" ), tr( "C&enter" ), CTRL + Key_E, grp, "textCenter" );
actionAlignCenter->setToggleAction( TRUE );
actionAlignRight = new QAction( QPixmap::fromMimeSource( "textright.xpm" ), tr( "&Right" ), CTRL + Key_R, grp, "textRight" );
actionAlignRight->setToggleAction( TRUE );
actionAlignJustify = new QAction( QPixmap::fromMimeSource( "textjustify.xpm" ), tr( "&Justify" ), CTRL + Key_J, grp, "textjustify" );
actionAlignJustify->setToggleAction( TRUE );
grp->addTo( tb );
grp->addTo( menu );
menu->insertSeparator();
QPixmap pix( 16, 16 );
pix.fill( black );
actionTextColor = new QAction( pix, tr( "&Color..." ), 0, this, "textColor" );
connect( actionTextColor, SIGNAL( activated() ), this, SLOT( textColor() ) );
actionTextColor->addTo( tb );
actionTextColor->addTo( menu );
}
示例8: settings
//.........这里部分代码省略.........
}
}
ui->buttonMainColor->setColor(palette().color(QPalette::Active, QPalette::Button));
ui->buttonWindowColor->setColor(palette().color(QPalette::Active, QPalette::Window));
connect(ui->buttonMainColor, SIGNAL(colorChanged(QColor)), SLOT(buildPalette()));
connect(ui->buttonWindowColor, SIGNAL(colorChanged(QColor)), SLOT(buildPalette()));
#ifdef Q_WS_X11
if (X11->desktopEnvironment == DE_KDE)
ui->colorConfig->hide();
else
ui->kdeNoteLabel->hide();
#else
ui->colorConfig->hide();
ui->kdeNoteLabel->hide();
#endif
QFontDatabase db;
QStringList families = db.families();
ui->fontFamilyCombo->addItems(families);
QStringList fs = families;
QStringList fs2 = QFont::substitutions();
QStringList::Iterator fsit = fs2.begin();
while (fsit != fs2.end()) {
if (!fs.contains(*fsit))
fs += *fsit;
fsit++;
}
fs.sort();
ui->familySubstitutionCombo->addItems(fs);
ui->chooseSubstitutionCombo->addItems(families);
QList<int> sizes = db.standardSizes();
foreach(int i, sizes)
ui->pointSizeCombo->addItem(QString::number(i));
ui->doubleClickIntervalSpinBox->setValue(QApplication::doubleClickInterval());
ui->cursorFlashTimeSpinBox->setValue(QApplication::cursorFlashTime());
ui->wheelScrollLinesSpinBox->setValue(QApplication::wheelScrollLines());
// #############
// resolveLinksCheckBox->setChecked(qt_resolve_symlinks);
ui->effectsCheckBox->setChecked(QApplication::isEffectEnabled(Qt::UI_General));
ui->effectsFrame->setEnabled(ui->effectsCheckBox->isChecked());
if (QApplication::isEffectEnabled(Qt::UI_FadeMenu))
ui->menuEffectCombo->setCurrentIndex(2);
else if (QApplication::isEffectEnabled(Qt::UI_AnimateMenu))
ui->menuEffectCombo->setCurrentIndex(1);
if (QApplication::isEffectEnabled(Qt::UI_AnimateCombo))
ui->comboEffectCombo->setCurrentIndex(1);
if (QApplication::isEffectEnabled(Qt::UI_FadeTooltip))
ui->toolTipEffectCombo->setCurrentIndex(2);
else if (QApplication::isEffectEnabled(Qt::UI_AnimateTooltip))
ui->toolTipEffectCombo->setCurrentIndex(1);
if (QApplication::isEffectEnabled(Qt::UI_AnimateToolBox))
ui->toolBoxEffectCombo->setCurrentIndex(1);
QSize globalStrut = QApplication::globalStrut();
ui->strutWidthSpinBox->setValue(globalStrut.width());
ui->strutHeightSpinBox->setValue(globalStrut.height());
示例9: FontResizer
FontResizer(Type type_) : type(type_) {
QFontDatabase fontDB;
defaultSizes = fontDB.standardSizes();
}