本文整理汇总了C++中QSizePolicy::verticalPolicy方法的典型用法代码示例。如果您正苦于以下问题:C++ QSizePolicy::verticalPolicy方法的具体用法?C++ QSizePolicy::verticalPolicy怎么用?C++ QSizePolicy::verticalPolicy使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QSizePolicy
的用法示例。
在下文中一共展示了QSizePolicy::verticalPolicy方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: valueToString
QString KPropertySizePolicyDelegate::valueToString(const QVariant& value, const QLocale &locale) const
{
const QSizePolicy sp(value.value<QSizePolicy>());
if (locale.language() == QLocale::C) {
return QString::fromLatin1("%1, %2, %3, %4")
.arg(KPropertyUtils::keyForEnumValue("SizePolicy", sp.horizontalPolicy()))
.arg(KPropertyUtils::keyForEnumValue("SizePolicy", sp.verticalPolicy()))
.arg(sp.horizontalStretch())
.arg(sp.verticalStretch());
}
return QObject::tr("%1, %2, %3, %4", "Size Policy")
.arg(s_sizePolicyListData->nameForPolicy(sp.horizontalPolicy()))
.arg(s_sizePolicyListData->nameForPolicy(sp.verticalPolicy()))
.arg(locale.toString(sp.horizontalStretch()))
.arg(locale.toString(sp.verticalStretch()));
}
示例2: setValue
void SizePolicyComposedProperty::setValue(Property *property,
const QVariant &value, bool rememberOldValue)
{
const QSizePolicy sp( value.value<QSizePolicy>() );
property->child("hor_policy")->setValue(sp.horizontalPolicy(), rememberOldValue, false);
property->child("vert_policy")->setValue(sp.verticalPolicy(), rememberOldValue, false);
property->child("hor_stretch")->setValue(sp.horizontalStretch(), rememberOldValue, false);
property->child("vert_stretch")->setValue(sp.verticalStretch(), rememberOldValue, false);
}
示例3: setGeometry
/*!
\reimp
*/
void QWidgetItem::setGeometry(const QRect &rect)
{
if (isEmpty())
return;
QRect r = !wid->testAttribute(Qt::WA_LayoutUsesWidgetRect)
? fromLayoutItemRect(wid->d_func(), rect)
: rect;
const QSize widgetRectSurplus = r.size() - rect.size();
/*
For historical reasons, this code is done using widget rect
coordinates, not layout item rect coordinates. However,
QWidgetItem's sizeHint(), maximumSize(), and heightForWidth()
all work in terms of layout item rect coordinates, so we have to
add or subtract widgetRectSurplus here and there. The code could
be much simpler if we did everything using layout item rect
coordinates and did the conversion right before the call to
QWidget::setGeometry().
*/
QSize s = r.size().boundedTo(maximumSize() + widgetRectSurplus);
int x = r.x();
int y = r.y();
if (align & (Qt::AlignHorizontal_Mask | Qt::AlignVertical_Mask)) {
QSize pref(sizeHint());
QSizePolicy sp = wid->sizePolicy();
if (sp.horizontalPolicy() == QSizePolicy::Ignored)
pref.setWidth(wid->sizeHint().expandedTo(wid->minimumSize()).width());
if (sp.verticalPolicy() == QSizePolicy::Ignored)
pref.setHeight(wid->sizeHint().expandedTo(wid->minimumSize()).height());
pref += widgetRectSurplus;
if (align & Qt::AlignHorizontal_Mask)
s.setWidth(qMin(s.width(), pref.width()));
if (align & Qt::AlignVertical_Mask) {
if (hasHeightForWidth())
s.setHeight(qMin(s.height(),
heightForWidth(s.width() - widgetRectSurplus.width())
+ widgetRectSurplus.height()));
else
s.setHeight(qMin(s.height(), pref.height()));
}
}
Qt::Alignment alignHoriz = QStyle::visualAlignment(wid->layoutDirection(), align);
if (alignHoriz & Qt::AlignRight)
x = x + (r.width() - s.width());
else if (!(alignHoriz & Qt::AlignLeft))
x = x + (r.width() - s.width()) / 2;
if (align & Qt::AlignBottom)
y = y + (r.height() - s.height());
else if (!(align & Qt::AlignTop))
y = y + (r.height() - s.height()) / 2;
wid->setGeometry(x, y, s.width(), s.height());
}
示例4: displayText
QString SizePolicyDelegate::displayText( const QVariant& value ) const
{
const QSizePolicy sp(value.value<QSizePolicy>());
return QString::fromLatin1(SIZEPOLICY_MASK)
.arg(s_sizePolicyListData->nameForPolicy(sp.horizontalPolicy()))
.arg(s_sizePolicyListData->nameForPolicy(sp.verticalPolicy()))
.arg(sp.horizontalStretch())
.arg(sp.verticalStretch());
}
示例5: WBHistoryCompletionModel
WBWebView *WBTabWidget::newTab(bool makeCurrent)
{
// line edit
WBUrlLineEdit *urlLineEdit = new WBUrlLineEdit;
QSizePolicy urlPolicy = urlLineEdit->sizePolicy();
urlLineEdit->setSizePolicy(QSizePolicy::MinimumExpanding, urlPolicy.verticalPolicy());
QLineEdit *lineEdit = urlLineEdit->lineEdit();
QSizePolicy policy = lineEdit->sizePolicy();
lineEdit->setSizePolicy(QSizePolicy::MinimumExpanding, policy.verticalPolicy());
if (!mLineEditCompleter && count() > 0)
{
WBHistoryCompletionModel *completionModel = new WBHistoryCompletionModel(this);
completionModel->setSourceModel(WBBrowserWindow::historyManager()->historyFilterModel());
mLineEditCompleter = new QCompleter(completionModel, this);
// Should this be in Qt by default?
QAbstractItemView *popup = mLineEditCompleter->popup();
QListView *listView = qobject_cast<QListView*>(popup);
if (listView)
listView->setUniformItemSizes(true);
}
lineEdit->setCompleter(mLineEditCompleter);
connect(lineEdit, SIGNAL(returnPressed()), this, SLOT(lineEditReturnPressed()));
mLineEdits->addWidget(urlLineEdit);
mLineEdits->setSizePolicy(lineEdit->sizePolicy());
// optimization to delay creating the more expensive WebView, history, etc
if (count() == 0)
{
QWidget *emptyWidget = new QWidget;
QPalette p = emptyWidget->palette();
p.setColor(QPalette::Window, palette().color(QPalette::Base));
emptyWidget->setPalette(p);
emptyWidget->setAutoFillBackground(true);
disconnect(this, SIGNAL(currentChanged(int)), this, SLOT(currentChanged(int)));
addTab(emptyWidget, tr("(Untitled)"));
connect(this, SIGNAL(currentChanged(int)), this, SLOT(currentChanged(int)));
return 0;
}
示例6: ExLineEdit
/*
SearchLineEdit is an enhanced QLineEdit
- A Search icon on the left with optional menu
- When there is no text and doesn't have focus an "inactive text" is displayed
- When there is text a clear button is displayed on the right hand side
*/
SearchLineEdit::SearchLineEdit(QWidget *parent) : ExLineEdit(parent),
m_searchButton(new SearchButton(this))
{
connect(lineEdit(), SIGNAL(textChanged(QString)),
this, SIGNAL(textChanged(QString)));
setLeftWidget(m_searchButton);
m_inactiveText = tr("Search");
QSizePolicy policy = sizePolicy();
setSizePolicy(QSizePolicy::Preferred, policy.verticalPolicy());
}
示例7: toString
QString LayoutDumper::toString(const QSizePolicy& policy)
{
QString result = QString("(%1, %2)")
.arg(toString(policy.horizontalPolicy()))
.arg(toString(policy.verticalPolicy()));
if (policy.hasHeightForWidth()) {
result += " [hasHeightForWidth]";
}
if (policy.hasWidthForHeight()) {
result += " [hasWidthForHeight]";
}
return result;
}
示例8: sizePolicyToString
static QString sizePolicyToString(const QSizePolicy &p)
{
QString rc; {
QTextStream str(&rc);
str << "Control=" << p.controlType() << " expdirs=" << p.expandingDirections()
<< " hasHeightForWidth=" << p.hasHeightForWidth()
<< " H: Policy=" << p.horizontalPolicy()
<< " stretch=" << p.horizontalStretch()
<< " V: Policy=" << p.verticalPolicy()
<< " stretch=" << p.verticalStretch();
}
return rc;
}
示例9: WBExLineEdit
/*
SearchLineEdit is an enhanced QLineEdit
- A Search icon on the left with optional menu
- When there is no text and doesn't have focus an "inactive text" is displayed
- When there is text a clear button is displayed on the right hand side
*/
WBSearchLineEdit::WBSearchLineEdit(QWidget *parent)
: WBExLineEdit(parent),
mSearchButton(new WBSearchButton(this))
{
connect(lineEdit(), SIGNAL(textChanged(const QString &)),
this, SIGNAL(textChanged(const QString &)));
setLeftWidget(mSearchButton);
mInactiveText = tr("Search");
setMinimumWidth(150);
QSizePolicy policy = sizePolicy();
setSizePolicy(QSizePolicy::Maximum, policy.verticalPolicy());
}
示例10: ExLineEdit
SearchLineEdit::SearchLineEdit(QWidget *parent)
: ExLineEdit(parent), searchButton(new SearchButton(this)) {
connect(m_lineEdit, SIGNAL(textChanged(const QString &)), SIGNAL(textChanged(const QString &)));
connect(m_lineEdit, SIGNAL(textEdited(const QString &)), SIGNAL(textEdited(const QString &)));
connect(m_lineEdit, SIGNAL(returnPressed()), SLOT(returnPressed()));
setLeftWidget(searchButton);
inactiveText = tr("Search");
QSizePolicy policy = sizePolicy();
setSizePolicy(QSizePolicy::Preferred, policy.verticalPolicy());
// completion
autoComplete = new AutoComplete(this, m_lineEdit);
connect(autoComplete, SIGNAL(suggestionAccepted(Suggestion *)),
SIGNAL(suggestionAccepted(Suggestion *)));
}
示例11: LineEdit
/*
SearchLineEdit is an enhanced QLineEdit
- A Search icon on the left with optional menu
- When there is no text and doesn't have focus an "inactive text" is displayed
- When there is text a clear button is displayed on the right hand side
*/
SearchLineEdit::SearchLineEdit(QWidget *parent)
: LineEdit(parent)
, m_searchButton(new SearchButton(this))
{
addWidget(m_searchButton, LeftSide);
m_inactiveText = tr("Search");
QSizePolicy policy = sizePolicy();
setSizePolicy(QSizePolicy::Preferred, policy.verticalPolicy());
// clear button on the right
ClearButton *m_clearButton = new ClearButton(this);
connect(m_clearButton, SIGNAL(clicked()),
this, SLOT(clear()));
connect(this, SIGNAL(textChanged(const QString&)),
m_clearButton, SLOT(textChanged(const QString&)));
addWidget(m_clearButton, RightSide);
m_clearButton->hide();
}
示例12: updateSizeHints
void AnimatedFrame::updateSizeHints()
{
if(widget_) {
QSize hint = widget_->minimumSizeHint();
if(!hint.isValid())
hint = widget_->sizeHint();
QSizePolicy policy = widget_->sizePolicy();
if(edge_ == kNorth || edge_ == kSouth) {
int minimum = widget_->minimumHeight();
int maximum = widget_->maximumHeight();
minimumSizeHint_.setWidth(0);
minimumSizeHint_.setHeight(qBound(minimum, hint.height(), maximum));
setSizePolicy(policy.horizontalPolicy(), QSizePolicy::Maximum);
}
else {
int minimum = widget_->minimumWidth();
int maximum = widget_->maximumWidth();
minimumSizeHint_.setWidth(qBound(minimum, hint.width(), maximum));
minimumSizeHint_.setHeight(0);
setSizePolicy(QSizePolicy::Maximum, policy.verticalPolicy());
}
setMinimumSize(widget_->minimumSize());
setMaximumSize(widget_->maximumSize());
}
else {
minimumSizeHint_ = QSize();
setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred);
}
sizeHint_ = minimumSizeHint_;
if(isUnfolded())
updateGeometry();
}
示例13:
osg::GraphicsContext::Traits* GraphicsWindowQt::createTraits( const QGLWidget* widget )
{
osg::GraphicsContext::Traits *traits = new osg::GraphicsContext::Traits;
qglFormat2traits( widget->format(), traits );
QRect r = widget->geometry();
traits->x = r.x();
traits->y = r.y();
traits->width = r.width();
traits->height = r.height();
traits->windowName = widget->windowTitle().toLocal8Bit().data();
Qt::WindowFlags f = widget->windowFlags();
traits->windowDecoration = ( f & Qt::WindowTitleHint ) &&
( f & Qt::WindowMinMaxButtonsHint ) &&
( f & Qt::WindowSystemMenuHint );
QSizePolicy sp = widget->sizePolicy();
traits->supportsResize = sp.horizontalPolicy() != QSizePolicy::Fixed ||
sp.verticalPolicy() != QSizePolicy::Fixed;
return traits;
}
示例14: QTabWidget
WBTabWidget::WBTabWidget(QWidget *parent)
: QTabWidget(parent)
, mRecentlyClosedTabsMenu(0)
, mLineEditCompleter(0)
, mLineEdits(0)
, mTabBar(new WBTabBar(this))
{
setObjectName("ubWebBrowserTabWidget");
mAddTabIcon = QPixmap(":/images/toolbar/plusBlack.png");
setElideMode(Qt::ElideRight);
connect(mTabBar, SIGNAL(newTab()), this, SLOT(newTab()));
connect(mTabBar, SIGNAL(closeTab(int)), this, SLOT(closeTab(int)));
connect(mTabBar, SIGNAL(cloneTab(int)), this, SLOT(cloneTab(int)));
connect(mTabBar, SIGNAL(closeOtherTabs(int)), this, SLOT(closeOtherTabs(int)));
connect(mTabBar, SIGNAL(reloadTab(int)), this, SLOT(reloadTab(int)));
connect(mTabBar, SIGNAL(reloadAllTabs()), this, SLOT(reloadAllTabs()));
connect(mTabBar, SIGNAL(tabMoved(int, int)), this, SLOT(moveTab(int, int)));
setTabBar(mTabBar);
setDocumentMode(false);
mRecentlyClosedTabsMenu = new QMenu(this);
connect(mRecentlyClosedTabsMenu, SIGNAL(aboutToShow()), this, SLOT(aboutToShowRecentTabsMenu()));
connect(mRecentlyClosedTabsMenu, SIGNAL(triggered(QAction *)), this, SLOT(aboutToShowRecentTriggeredAction(QAction *)));
mRecentlyClosedTabsAction = new QAction(tr("Recently Closed Tabs"), this);
mRecentlyClosedTabsAction->setMenu(mRecentlyClosedTabsMenu);
mRecentlyClosedTabsAction->setEnabled(false);
connect(this, SIGNAL(currentChanged(int)), this, SLOT(currentChanged(int)));
mLineEdits = new QStackedWidget(this);
mLineEdits->setMinimumWidth(200);
QSizePolicy spolicy = mLineEdits->sizePolicy();
mLineEdits->setSizePolicy(QSizePolicy::Maximum, spolicy.verticalPolicy());
}
示例15: LineEdit
/*
SearchLineEdit is an enhanced QLineEdit
- A Search icon on the left with optional menu
- When there is no text and doesn't have focus an "inactive text" is displayed
- When there is text a clear button is displayed on the right hand side
*/
SearchLineEdit::SearchLineEdit(QWidget *parent)
: LineEdit(parent)
, m_searchButton(0)
{
setUpdatesEnabled(false);
m_searchButton = new SearchButton(this);
updateGeometries();
addWidget(m_searchButton, LeftSide);
setInactiveText(tr("Search"));
QSizePolicy policy = sizePolicy();
setSizePolicy(QSizePolicy::Preferred, policy.verticalPolicy());
// clear button on the right
ClearButton *m_clearButton = new ClearButton(this);
connect(m_clearButton, SIGNAL(clicked()),
this, SLOT(clear()));
connect(this, SIGNAL(textChanged(const QString&)),
m_clearButton, SLOT(textChanged(const QString&)));
addWidget(m_clearButton, RightSide);
m_clearButton->hide();
updateTextMargins();
setUpdatesEnabled(true);
}