本文整理汇总了C++中QWidget::font方法的典型用法代码示例。如果您正苦于以下问题:C++ QWidget::font方法的具体用法?C++ QWidget::font怎么用?C++ QWidget::font使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QWidget
的用法示例。
在下文中一共展示了QWidget::font方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: setIndexWidget
void ItemDelegate::setIndexWidget(const QModelIndex &index, ItemWidget *w)
{
reset(&m_cache[index.row()], w);
if (w == NULL)
return;
QWidget *ww = w->widget();
if (!m_antialiasing) {
QFont f = ww->font();
f.setStyleStrategy(QFont::NoAntialias);
ww->setFont(f);
foreach (QWidget *child, ww->findChildren<QWidget *>("item_child"))
child->setFont(f);
}
// Try to get proper size by showing item momentarily.
ww->show();
w->updateSize(m_maxSize, m_idealWidth);
ww->hide();
ww->installEventFilter(this);
w->setCurrent(m_view->currentIndex() == index);
emit rowSizeChanged();
}
示例2: resizeFont
void csFontResizer::resizeFont(QObject *watched, const int size, const int increment)
{
if( (size == 0 && increment == 0) ||
(size != 0 && increment != 0) ) {
return;
}
QWidget *widget = dynamic_cast<QWidget*>(watched);
if( widget == 0 ) {
return;
}
QFont font = widget->font();
if( !defSize.contains(widget) ) {
defSize.insert(widget, font.pointSize());
}
int newSize(0);
if( size != 0 ) {
newSize = qBound(minSize, size, maxSize);
} else if( increment != 0 ) {
newSize = qBound(minSize, font.pointSize() + increment, maxSize);
}
if( newSize > 0 ) {
font.setPointSize(newSize);
}
widget->setFont(font);
}
示例3: QAbstractTableModel
QgsVertexEditorModel::QgsVertexEditorModel( QgsVectorLayer *layer, QgsSelectedFeature *selectedFeature, QgsMapCanvas *canvas, QObject *parent )
: QAbstractTableModel( parent )
, mLayer( layer )
, mSelectedFeature( selectedFeature )
, mCanvas( canvas )
, mHasZ( false )
, mHasM( false )
, mHasR( true ) //always show for now - avoids scanning whole feature for curves TODO - avoid this
, mZCol( -1 )
, mMCol( -1 )
, mRCol( -1 )
{
QgsWkbTypes::Type layerWKBType = mLayer->wkbType();
mHasZ = QgsWkbTypes::hasZ( layerWKBType );
mHasM = QgsWkbTypes::hasM( layerWKBType );
if ( mHasZ )
mZCol = 2;
if ( mHasM )
mMCol = 2 + ( mHasZ ? 1 : 0 );
if ( mHasR )
mRCol = 2 + ( mHasZ ? 1 : 0 ) + ( mHasM ? 1 : 0 );
QWidget *parentWidget = dynamic_cast< QWidget * >( parent );
if ( parentWidget )
{
mWidgetFont = parentWidget->font();
}
}
示例4: QAbstractTableModel
QgsVertexEditorModel::QgsVertexEditorModel( QgsMapCanvas *canvas, QObject *parent )
: QAbstractTableModel( parent )
, mCanvas( canvas )
{
QWidget *parentWidget = dynamic_cast< QWidget * >( parent );
if ( parentWidget )
mWidgetFont = parentWidget->font();
}
示例5: setFontSize
void NWidgetPrototype::setFontSize(int size)
{
QWidget *widget = qscriptvalue_cast<QWidget *>(thisObject());
if (widget) {
QFont font = widget->font();
font.setPixelSize(size);
widget->setFont(font);
}
}
示例6: resetFontSize
void DocumentBrowser::resetFontSize()
{
int fontSize = m_liteApp->settings()->value(DOCUMENT_FONTSIZE,12).toInt();
m_liteApp->settings()->setValue(DOCUMENT_FONTZOOM,100);
QWidget *widget = m_htmlWidget->widget();
QFont font = widget->font();
font.setPointSize(fontSize);
widget->setFont(font);
}
示例7: requestFontZoom
void DocumentBrowser::requestFontZoom(int zoom)
{
int fontSize = m_liteApp->settings()->value(DOCUMENT_FONTSIZE,12).toInt();
int fontZoom = m_liteApp->settings()->value(DOCUMENT_FONTZOOM,100).toInt();
fontZoom += zoom;
if (fontZoom <= 10) {
return;
}
m_liteApp->settings()->setValue(DOCUMENT_FONTZOOM,fontZoom);
QWidget *widget = m_htmlWidget->widget();
QFont font = widget->font();
font.setPointSize(fontSize*fontZoom/100.0);
widget->setFont(font);
}
示例8: zoomFontSizeSub
void View::zoomFontSizeSub(int zoom, const QList<QWidget*>& widgets)
{
int n = widgets.size();
for(int i=0; i < n; ++i){
QWidget* widget = widgets[i];
QFont font = widget->font();
font.setPointSize(font.pointSize() + zoom);
widget->setFont(font);
// The following recursive iteration is disabled because
// it makes doubled zooming for some composite widgets
// zoomFontSizeSub(zoom, widget->findChildren<QWidget*>());
}
}
示例9: updateEditorGeometry
void ContactItemDelegate::updateEditorGeometry(QWidget *editor, const QStyleOptionViewItem &option, const QModelIndex &index) const
{
Q_UNUSED(index);
/* Container is the full size of the index */
editor->setGeometry(option.rect);
QWidget *widget = editor->focusProxy();
if (widget)
{
QFontMetrics fm(widget->font());
widget->setGeometry(QRect(46, 5, option.rect.width()-70, fm.height()));
}
}
示例10: main
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
QStringList args = app.arguments();
(void) args.takeFirst();
QWidget *widget = 0;
QString title;
bool usePlainTextEdit = args.size() < 2;
if (usePlainTextEdit) {
widget = new QPlainTextEdit;
title = "PlainTextEdit";
} else {
widget = new QTextEdit;
title = "TextEdit";
}
widget->resize(450, 350);
widget->setFocus();
FakeVimHandler fakeVim;
QMainWindow mw;
mw.setWindowTitle("Fakevim (" + title + ")");
mw.setCentralWidget(widget);
mw.resize(500, 650);
mw.move(0, 0);
mw.show();
QFont font = widget->font();
//: -misc-fixed-medium-r-semicondensed--13-120-75-75-c-60-iso8859-1
//font.setFamily("Misc");
font.setFamily("Monospace");
//font.setStretch(QFont::SemiCondensed);
widget->setFont(font);
mw.statusBar()->setFont(font);
QObject::connect(&fakeVim, SIGNAL(commandBufferChanged(QString)),
mw.statusBar(), SLOT(showMessage(QString)));
QObject::connect(&fakeVim, SIGNAL(quitRequested(QWidget *)),
&app, SLOT(quit()));
fakeVim.addWidget(widget);
if (args.size() >= 1)
fakeVim.handleCommand(widget, "r " + args.at(0));
return app.exec();
}
示例11: sizeHint
QSize KxMenuItemWidget::sizeHint() const
{
// Do not give invisible menu items any space
if(!fMenuItem->isVisible()) return QSize(0,0);
QSize sz;
QWidget *q = parentWidget();
QStyleOptionMenuItem opt = getStyleOption();
KxMenuItem *action = fMenuItem;
const int hmargin = q->style()->pixelMetric(QStyle::PM_MenuDesktopFrameWidth, 0, q),
iconWidth = q->style()->pixelMetric(QStyle::PM_SmallIconSize, 0, q);
QFontMetrics fm(action->font().resolve(q->font()));
if (action->isSeparator()) {
sz = QSize(2, 2);
} else {
// Text
QString s = action->text();
int w = fm.width(s);
QKeySequence shortcutSeq = fMenuItem->shortcut();
sz.setWidth(w);
sz.setHeight(fm.height());
// Keyboard shortcut
if(!shortcutSeq.isEmpty()) {
QString shortcut = shortcutSeq.toString(QKeySequence::NativeText);
w = fm.width(shortcut);
sz.rwidth() += w + kShortcutRightMargin;
}
// Checkbox
if(action->isCheckable()) {
sz.rwidth() += iconWidth;
}
// option boxes
sz.rwidth() += iconWidth;
// Margins
sz.rwidth() += 2 * hmargin;
}
opt.rect = q->rect();
sz = q->style()->sizeFromContents(QStyle::CT_MenuItem, &opt, sz, q);
return sz;
}
示例12: loadXML
void VCLabel_Test::loadXML()
{
QLCFixtureDefCache fdc;
Doc doc(this, fdc);
OutputMap om(this, 4);
InputMap im(this, 4);
MasterTimer mt(this, &om);
QWidget w;
QDomDocument xmldoc;
QDomElement root = xmldoc.createElement("Label");
xmldoc.appendChild(root);
QDomElement wstate = xmldoc.createElement("WindowState");
wstate.setAttribute("Width", "42");
wstate.setAttribute("Height", "69");
wstate.setAttribute("X", "3");
wstate.setAttribute("Y", "4");
wstate.setAttribute("Visible", "True");
root.appendChild(wstate);
QDomElement appearance = xmldoc.createElement("Appearance");
QFont f(w.font());
f.setPointSize(f.pointSize() + 3);
QDomElement font = xmldoc.createElement("Font");
QDomText fontText = xmldoc.createTextNode(f.toString());
font.appendChild(fontText);
appearance.appendChild(font);
root.appendChild(appearance);
QDomElement foobar = xmldoc.createElement("Foobar");
root.appendChild(foobar);
VCLabel label(&w, &doc, &om, &im, &mt);
QVERIFY(label.loadXML(&root) == true);
QCOMPARE(label.geometry().width(), 42);
QCOMPARE(label.geometry().height(), 69);
QCOMPARE(label.geometry().x(), 3);
QCOMPARE(label.geometry().y(), 4);
QCOMPARE(label.font(), f);
root.setTagName("Lable");
QVERIFY(label.loadXML(&root) == false);
}
示例13: setDefaultFontSize
void WidgetSizeHelper::setDefaultFontSize(QWidget* pWidget) {
// we get all of pWidget's children
QObjectList children = pWidget->children();
// for each child
for ( int i = 0; i < children.length(); i++ ) {
/*
* we change its font size if it is of one of those types
*
* - QLabel
* - QLineEdit
* - QRadioButton
* - QGroupBox
* - QCheckBox
* - QStatusBar
*/
QWidget* pChild = static_cast<QWidget*> ( children.at(i) );
if ( qobject_cast<QLabel*>(pChild) != NULL ||
qobject_cast<QLineEdit*>(pChild) != NULL ||
qobject_cast<QRadioButton*>(pChild) != NULL ||
qobject_cast<QGroupBox*>(pChild) != NULL ||
qobject_cast<QCheckBox*>(pChild) != NULL ||
qobject_cast<QStatusBar*>(pChild) != NULL )
{
QFont lFont = pChild->font();
lFont.setPointSize(Constants::MAC_FONT_SIZE);
pChild->setFont(lFont);
}
// and scan it, if it has children
if ( ! pChild->children().isEmpty() ) {
setDefaultFontSize( pChild );
}
}
}
示例14: QAbstractTableModel
QgsNodeEditorModel::QgsNodeEditorModel( QgsVectorLayer* layer, QgsSelectedFeature* selectedFeature, QgsMapCanvas* canvas, QObject* parent )
: QAbstractTableModel( parent )
, mLayer( layer )
, mSelectedFeature( selectedFeature )
, mCanvas( canvas )
, mHasZ( false )
, mHasM( false )
, mHasR( true ) //always show for now - avoids scanning whole feature for curves TODO - avoid this
, mZCol( -1 )
, mMCol( -1 )
, mRCol( -1 )
{
if ( !mSelectedFeature->vertexMap().isEmpty() )
{
mHasZ = mSelectedFeature->vertexMap().at( 0 )->point().is3D();
mHasM = mSelectedFeature->vertexMap().at( 0 )->point().isMeasure();
if ( mHasZ )
mZCol = 2;
if ( mHasM )
mMCol = 2 + ( mHasZ ? 1 : 0 );
if ( mHasR )
mRCol = 2 + ( mHasZ ? 1 : 0 ) + ( mHasM ? 1 : 0 );
}
QWidget* parentWidget = dynamic_cast< QWidget* >( parent );
if ( parentWidget )
{
mWidgetFont = parentWidget->font();
}
connect( mSelectedFeature, SIGNAL( vertexMapChanged() ), this, SLOT( featureChanged() ) );
}
示例15: resetFont
void tst_QFont::resetFont()
{
QWidget parent;
QFont parentFont = parent.font();
parentFont.setPointSize(parentFont.pointSize() + 2);
parent.setFont(parentFont);
QWidget *child = new QWidget(&parent);
QFont childFont = child->font();
childFont.setBold(!childFont.bold());
child->setFont(childFont);
QVERIFY(parentFont.resolve() != 0);
QVERIFY(childFont.resolve() != 0);
QVERIFY(childFont != parentFont);
child->setFont(QFont()); // reset font
QVERIFY(child->font().resolve() == 0);
QVERIFY(child->font().pointSize() == parent.font().pointSize());
QVERIFY(parent.font().resolve() != 0);
}