本文整理汇总了C++中QDockWidget::fontMetrics方法的典型用法代码示例。如果您正苦于以下问题:C++ QDockWidget::fontMetrics方法的具体用法?C++ QDockWidget::fontMetrics怎么用?C++ QDockWidget::fontMetrics使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QDockWidget
的用法示例。
在下文中一共展示了QDockWidget::fontMetrics方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: titleHeight
int QDockWidgetLayout::titleHeight() const
{
QDockWidget *q = qobject_cast<QDockWidget*>(parentWidget());
if (QWidget *title = widgetForRole(TitleBar))
return perp(verticalTitleBar, title->sizeHint());
QSize closeSize(0, 0);
QSize floatSize(0, 0);
if (QLayoutItem *item = item_list[CloseButton])
closeSize = item->widget()->sizeHint();
if (QLayoutItem *item = item_list[FloatButton])
floatSize = item->widget()->sizeHint();
int buttonHeight = qMax(perp(verticalTitleBar, closeSize),
perp(verticalTitleBar, floatSize));
QFontMetrics titleFontMetrics = q->fontMetrics();
#ifdef Q_WS_MAC
if (qobject_cast<QMacStyle *>(q->style())) {
//### this breaks on proxy styles. (But is this code still called?)
QFont font = qt_app_fonts_hash()->value("QToolButton", q->font());
titleFontMetrics = QFontMetrics(font);
}
#endif
int mw = q->style()->pixelMetric(QStyle::PM_DockWidgetTitleMargin, 0, q);
return qMax(buttonHeight + 2, titleFontMetrics.height() + 2*mw);
}
示例2: titleHeight
int QDockWidgetLayout::titleHeight() const
{
QDockWidget *q = qobject_cast<QDockWidget*>(parentWidget());
if (QWidget *title = widget(TitleBar))
return perp(verticalTitleBar, title->sizeHint());
QSize closeSize(0, 0);
QSize floatSize(0, 0);
if (QLayoutItem *item = item_list[CloseButton])
closeSize = item->widget()->sizeHint();
if (QLayoutItem *item = item_list[FloatButton])
floatSize = item->widget()->sizeHint();
int buttonHeight = qMax(perp(verticalTitleBar, closeSize),
perp(verticalTitleBar, floatSize));
QFontMetrics titleFontMetrics = q->fontMetrics();
#ifdef Q_WS_MAC
if (qobject_cast<QMacStyle *>(q->style())) {
extern QHash<QByteArray, QFont> *qt_app_fonts_hash(); // qapplication.cpp
QFont font = qt_app_fonts_hash()->value("QToolButton", q->font());
titleFontMetrics = QFontMetrics(font);
}
#endif
int mw = q->style()->pixelMetric(QStyle::PM_DockWidgetTitleMargin, 0, q);
return qMax(buttonHeight + 2, titleFontMetrics.lineSpacing() + 2*mw);
}
示例3: sizeHint
QSize KoDockWidgetTitleBar::sizeHint() const
{
QDockWidget *q = qobject_cast<QDockWidget*>(parentWidget());
int mw = q->style()->pixelMetric(QStyle::PM_DockWidgetTitleMargin, 0, q);
int fw = q->style()->pixelMetric(QStyle::PM_DockWidgetFrameWidth, 0, q);
// get size of buttons...
QSize closeSize(0, 0);
if (d->closeButton && d->closeButton->isVisible()) {
closeSize = d->closeButton->sizeHint();
}
QSize floatSize(0, 0);
if (d->floatButton && d->floatButton->isVisible()) {
floatSize = d->floatButton->sizeHint();
}
QSize hideSize(0, 0);
if (d->collapseButton && d->collapseButton->isVisible()) {
hideSize = d->collapseButton->sizeHint();
}
int buttonHeight = qMax(qMax(closeSize.height(), floatSize.height()), hideSize.height()) + 2;
int buttonWidth = closeSize.width() + floatSize.width() + hideSize.width();
int height = buttonHeight;
if (d->textVisibilityMode == FullTextAlwaysVisible) {
// get font size
QFontMetrics titleFontMetrics = q->fontMetrics();
int fontHeight = titleFontMetrics.lineSpacing() + 2 * mw;
height = qMax(height, fontHeight);
}
/*
* Calculate the width of title and add to the total width of the docker window when collapsed.
*/
const int titleWidth =
(d->textVisibilityMode == FullTextAlwaysVisible) ? (q->fontMetrics().width(q->windowTitle()) + 2*mw) :
0;
if (d->preCollapsedWidth > 0) {
return QSize(d->preCollapsedWidth, height);
}
else {
return QSize(buttonWidth /*+ height*/ + 2*mw + 2*fw + titleWidth, height);
}
}
示例4: titleHeight
int QDockWidgetLayout::titleHeight() const
{
QDockWidget *q = qobject_cast<QDockWidget*>(parentWidget());
if (QWidget *title = widgetForRole(TitleBar))
return perp(verticalTitleBar, title->sizeHint());
QSize closeSize(0, 0);
QSize floatSize(0, 0);
if (QLayoutItem *item = item_list[CloseButton])
closeSize = item->widget()->sizeHint();
if (QLayoutItem *item = item_list[FloatButton])
floatSize = item->widget()->sizeHint();
int buttonHeight = qMax(perp(verticalTitleBar, closeSize),
perp(verticalTitleBar, floatSize));
QFontMetrics titleFontMetrics = q->fontMetrics();
int mw = q->style()->pixelMetric(QStyle::PM_DockWidgetTitleMargin, 0, q);
return qMax(buttonHeight + 2, titleFontMetrics.height() + 2*mw);
}