本文整理汇总了C++中QSizePolicy::horizontalStretch方法的典型用法代码示例。如果您正苦于以下问题:C++ QSizePolicy::horizontalStretch方法的具体用法?C++ QSizePolicy::horizontalStretch怎么用?C++ QSizePolicy::horizontalStretch使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QSizePolicy
的用法示例。
在下文中一共展示了QSizePolicy::horizontalStretch方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: showLibrary
void GUI_Player::showLibrary(bool b, bool resize)
{
m_settings->setNoShowLibrary(!b);
int old_width = this->width();
int lib_width = this->ui->library_widget->width();
int new_width = old_width;
this->ui->library_widget->setVisible(b);
if (!b) {
// invisble
QSizePolicy p = this->ui->library_widget->sizePolicy();
m_library_stretch_factor = p.horizontalStretch();
p.setHorizontalStretch(0);
this->ui->library_widget->setSizePolicy(p);
m_library_width = lib_width;
new_width = old_width - lib_width;
//this->setMinimumSize(300, 400);
} else {
// visible
QSizePolicy p = this->ui->library_widget->sizePolicy();
p.setHorizontalStretch(m_library_stretch_factor);
this->ui->library_widget->setSizePolicy(p);
new_width = old_width + m_library_width;
//this->setMinimumSize(650, 400);
}
if (resize) {
QRect rect = this->geometry();
rect.setWidth(new_width);
rect.setHeight(this->height());
this->setGeometry(rect);
}
}
示例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: 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: 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;
}
示例6: getWidgetSize
int QSplitterLayoutStruct::getWidgetSize(Qt::Orientation orient)
{
if (sizer == -1) {
QSize s = widget->sizeHint();
const int presizer = pick(s, orient);
const int realsize = pick(widget->size(), orient);
if (!s.isValid() || (widget->testAttribute(Qt::WA_Resized) && (realsize > presizer))) {
sizer = pick(widget->size(), orient);
} else {
sizer = presizer;
}
QSizePolicy p = widget->sizePolicy();
int sf = (orient == Qt::Horizontal) ? p.horizontalStretch() : p.verticalStretch();
if (sf > 1)
sizer *= sf;
}
return sizer;
}
示例7: getStretch
static int getStretch(const QWidget *w)
{
QSizePolicy sp = w->sizePolicy();
return qMax(sp.horizontalStretch(), sp.verticalStretch());
}
示例8: doResize
void QSplitterPrivate::doResize()
{
Q_Q(QSplitter);
QRect r = q->contentsRect();
int n = list.count();
QVector<QLayoutStruct> a(n*2);
int i;
bool noStretchFactorsSet = true;
for (i = 0; i < n; ++i) {
QSizePolicy p = list.at(i)->widget->sizePolicy();
int sf = orient == Qt::Horizontal ? p.horizontalStretch() : p.verticalStretch();
if (sf != 0) {
noStretchFactorsSet = false;
break;
}
}
int j=0;
for (i = 0; i < n; ++i) {
QSplitterLayoutStruct *s = list.at(i);
#ifdef QSPLITTER_DEBUG
qDebug("widget %d hidden: %d collapsed: %d handle hidden: %d", i, s->widget->isHidden(),
s->collapsed, s->handle->isHidden());
#endif
a[j].init();
if (s->handle->isHidden()) {
a[j].maximumSize = 0;
} else {
a[j].sizeHint = a[j].minimumSize = a[j].maximumSize = s->getHandleSize(orient);
a[j].empty = false;
}
++j;
a[j].init();
if (s->widget->isHidden() || s->collapsed) {
a[j].maximumSize = 0;
} else {
a[j].minimumSize = pick(qSmartMinSize(s->widget));
a[j].maximumSize = pick(s->widget->maximumSize());
a[j].empty = false;
bool stretch = noStretchFactorsSet;
if (!stretch) {
QSizePolicy p = s->widget->sizePolicy();
int sf = orient == Qt::Horizontal ? p.horizontalStretch() : p.verticalStretch();
stretch = (sf != 0);
}
if (stretch) {
a[j].stretch = s->getWidgetSize(orient);
a[j].sizeHint = a[j].minimumSize;
a[j].expansive = true;
} else {
a[j].sizeHint = qMax(s->getWidgetSize(orient), a[j].minimumSize);
}
}
++j;
}
qGeomCalc(a, 0, n*2, pick(r.topLeft()), pick(r.size()), 0);
#ifdef QSPLITTER_DEBUG
for (i = 0; i < n*2; ++i) {
qDebug("%*s%d: stretch %d, sh %d, minS %d, maxS %d, exp %d, emp %d -> %d, %d",
i, "", i,
a[i].stretch,
a[i].sizeHint,
a[i].minimumSize,
a[i].maximumSize,
a[i].expansive,
a[i].empty,
a[i].pos,
a[i].size);
}
#endif
for (i = 0; i < n; ++i) {
QSplitterLayoutStruct *s = list.at(i);
setGeo(s, a[i*2+1].pos, a[i*2+1].size, false);
}
}
示例9: applySimpleProperty
//.........这里部分代码省略.........
#ifndef QT_NO_CURSOR
case QVariant::Cursor: {
const QMetaEnum cursorShape_enum = metaEnum<QAbstractFormBuilderGadget>("cursorShape");
dom_prop->setElementCursorShape(QLatin1String(cursorShape_enum.valueToKey(qvariant_cast<QCursor>(v).shape())));
}
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);