本文整理汇总了C++中QSizePolicy::horizontalPolicy方法的典型用法代码示例。如果您正苦于以下问题:C++ QSizePolicy::horizontalPolicy方法的具体用法?C++ QSizePolicy::horizontalPolicy怎么用?C++ QSizePolicy::horizontalPolicy使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QSizePolicy
的用法示例。
在下文中一共展示了QSizePolicy::horizontalPolicy方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: smartMaxSize
void tst_QLayout::smartMaxSize()
{
QVector<int> expectedWidths;
QFile f(QFINDTESTDATA("baseline/smartmaxsize"));
QCOMPARE(f.open(QIODevice::ReadOnly | QIODevice::Text), true);
QTextStream stream(&f);
while(!stream.atEnd()) {
QString line = stream.readLine(200);
expectedWidths.append(line.section(QLatin1Char(' '), 6, -1, QString::SectionSkipEmpty).toInt());
}
f.close();
int sizeCombinations[] = { 0, 10, 20, QWIDGETSIZE_MAX};
QSizePolicy::Policy policies[] = { QSizePolicy::Fixed,
QSizePolicy::Minimum,
QSizePolicy::Maximum,
QSizePolicy::Preferred,
QSizePolicy::Expanding,
QSizePolicy::MinimumExpanding,
QSizePolicy::Ignored
};
Qt::Alignment alignments[] = { 0,
Qt::AlignLeft,
Qt::AlignRight,
Qt::AlignHCenter
};
int expectedIndex = 0;
int regressionCount = 0;
for (size_t p = 0; p < sizeof(policies)/sizeof(QSizePolicy::Policy); ++p) {
QSizePolicy sizePolicy;
sizePolicy.setHorizontalPolicy(policies[p]);
for (size_t min = 0; min < sizeof(sizeCombinations)/sizeof(int); ++min) {
int minSize = sizeCombinations[min];
for (size_t max = 0; max < sizeof(sizeCombinations)/sizeof(int); ++max) {
int maxSize = sizeCombinations[max];
for (size_t sh = 0; sh < sizeof(sizeCombinations)/sizeof(int); ++sh) {
int sizeHint = sizeCombinations[sh];
for (size_t a = 0; a < sizeof(alignments)/sizeof(int); ++a) {
Qt::Alignment align = alignments[a];
QSize sz = qSmartMaxSize(QSize(sizeHint, 1), QSize(minSize, 1), QSize(maxSize, 1), sizePolicy, align);
int width = sz.width();
int expectedWidth = expectedWidths[expectedIndex];
if (width != expectedWidth) {
qDebug() << "error at index" << expectedIndex << ":" << sizePolicy.horizontalPolicy() << align << minSize << sizeHint << maxSize << width;
++regressionCount;
}
++expectedIndex;
}
}
}
}
}
QCOMPARE(regressionCount, 0);
}
示例3: 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);
}
示例4: 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());
}
示例5: 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());
}
示例6: 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;
}
示例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: verticallyStretchButtons
void verticallyStretchButtons() {
/// do not vertically stretch if using transparent style sheet
if (makeInnerWidgetsTransparent) return;
/// check each widget inside MenuLineEdit
for (int i = hLayout->count() - 1; i >= 0; --i) {
QWidget *w = hLayout->itemAt(i)->widget();
if (w != NULL && w != m_singleLineEditText && w != m_multiLineEditText) {
/// for all widgets except the main editing widget: change tab focus policy
QSizePolicy sp = w->sizePolicy();
w->setSizePolicy(sp.horizontalPolicy(), QSizePolicy::MinimumExpanding);
}
}
}
示例9: sipConvertFromEnum
static PyObject *meth_QSizePolicy_horizontalPolicy(PyObject *sipSelf, PyObject *sipArgs)
{
PyObject *sipParseErr = NULL;
{
QSizePolicy *sipCpp;
if (sipParseArgs(&sipParseErr, sipArgs, "B", &sipSelf, sipType_QSizePolicy, &sipCpp))
{
QSizePolicy::Policy sipRes;
Py_BEGIN_ALLOW_THREADS
sipRes = sipCpp->horizontalPolicy();
Py_END_ALLOW_THREADS
return sipConvertFromEnum(sipRes,sipType_QSizePolicy_Policy);
}
}
示例10: 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();
}
示例11:
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;
}
示例12: applySimpleProperty
//.........这里部分代码省略.........
return true;
#endif
case QVariant::KeySequence: {
DomString *s = new DomString();
s->setText(qvariant_cast<QKeySequence>(v).toString(QKeySequence::PortableText));
dom_prop->setElementString(s);
}
return true;
case QVariant::Locale: {
DomLocale *dom = new DomLocale();
const QLocale locale = qvariant_cast<QLocale>(v);
const QMetaEnum language_enum = metaEnum<QAbstractFormBuilderGadget>("language");
const QMetaEnum country_enum = metaEnum<QAbstractFormBuilderGadget>("country");
dom->setAttributeLanguage(QLatin1String(language_enum.valueToKey(locale.language())));
dom->setAttributeCountry(QLatin1String(country_enum.valueToKey(locale.country())));
dom_prop->setElementLocale(dom);
}
return true;
case QVariant::SizePolicy: {
DomSizePolicy *dom = new DomSizePolicy();
const QSizePolicy sizePolicy = qvariant_cast<QSizePolicy>(v);
dom->setElementHorStretch(sizePolicy.horizontalStretch());
dom->setElementVerStretch(sizePolicy.verticalStretch());
const QMetaEnum sizeType_enum = metaEnum<QAbstractFormBuilderGadget>("sizeType");
dom->setAttributeHSizeType(QLatin1String(sizeType_enum.valueToKey(sizePolicy.horizontalPolicy())));
dom->setAttributeVSizeType(QLatin1String(sizeType_enum.valueToKey(sizePolicy.verticalPolicy())));
dom_prop->setElementSizePolicy(dom);
}
return true;
case QVariant::Date: {
DomDate *dom = new DomDate();
const QDate date = qvariant_cast<QDate>(v);
dom->setElementYear(date.year());
dom->setElementMonth(date.month());
dom->setElementDay(date.day());
dom_prop->setElementDate(dom);
}
return true;
case QVariant::Time: {
DomTime *dom = new DomTime();
const QTime time = qvariant_cast<QTime>(v);
dom->setElementHour(time.hour());
dom->setElementMinute(time.minute());
dom->setElementSecond(time.second());
dom_prop->setElementTime(dom);
}
return true;
case QVariant::DateTime: {
DomDateTime *dom = new DomDateTime();
示例13:
QDebug operator<<(QDebug dbg, const QSizePolicy &p)
{
dbg.nospace() << "QSizePolicy(horizontalPolicy = " << p.horizontalPolicy()
<< ", verticalPolicy = " << p.verticalPolicy() << ')';
return dbg.space();
}