本文整理汇总了C++中QSizePolicy::setHorStretch方法的典型用法代码示例。如果您正苦于以下问题:C++ QSizePolicy::setHorStretch方法的具体用法?C++ QSizePolicy::setHorStretch怎么用?C++ QSizePolicy::setHorStretch使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QSizePolicy
的用法示例。
在下文中一共展示了QSizePolicy::setHorStretch方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: setObjectProperty
//.........这里部分代码省略.........
if ( stdset )
v = "%1::%2";
else
v = "\"%1\"";
QString oc = objClass;
QString ev = e.firstChild().toText().data();
if ( oc == "QListView" && ev == "Manual" ) // #### workaround, rename QListView::Manual in 4.0
oc = "QScrollView";
if ( stdset )
v = v.arg( oc ).arg( ev );
else
v = v.arg( ev );
} else if ( e.tagName() == "set" ) {
QString keys( e.firstChild().toText().data() );
QStringList lst = QStringList::split( '|', keys );
v = "int( ";
QStringList::Iterator it = lst.begin();
while ( it != lst.end() ) {
v += objClass + "::" + *it;
if ( it != lst.fromLast() )
v += " | ";
++it;
}
v += " )";
} else if ( e.tagName() == "sizepolicy" ) {
QDomElement n3 = e.firstChild().toElement();
QSizePolicy sp;
while ( !n3.isNull() ) {
if ( n3.tagName() == "hsizetype" )
sp.setHorData( (QSizePolicy::SizeType)n3.firstChild().toText().data().toInt() );
else if ( n3.tagName() == "vsizetype" )
sp.setVerData( (QSizePolicy::SizeType)n3.firstChild().toText().data().toInt() );
else if ( n3.tagName() == "horstretch" )
sp.setHorStretch( n3.firstChild().toText().data().toInt() );
else if ( n3.tagName() == "verstretch" )
sp.setVerStretch( n3.firstChild().toText().data().toInt() );
n3 = n3.nextSibling().toElement();
}
QString tmp;
if ( !obj.isEmpty() )
tmp = obj + "->";
v = "QSizePolicy( (QSizePolicy::SizeType)%1, (QSizePolicy::SizeType)%2, %3, %4, " + tmp + "sizePolicy().hasHeightForWidth() )";
v = v.arg( (int)sp.horData() ).arg( (int)sp.verData() ).arg( sp.horStretch() ).arg( sp.verStretch() );
} else if ( e.tagName() == "palette" ) {
QPalette pal;
bool no_pixmaps = e.elementsByTagName( "pixmap" ).count() == 0;
QDomElement n;
if ( no_pixmaps ) {
n = e.firstChild().toElement();
while ( !n.isNull() ) {
QColorGroup cg;
if ( n.tagName() == "active" ) {
cg = loadColorGroup( n );
pal.setActive( cg );
} else if ( n.tagName() == "inactive" ) {
cg = loadColorGroup( n );
pal.setInactive( cg );
} else if ( n.tagName() == "disabled" ) {
cg = loadColorGroup( n );
pal.setDisabled( cg );
}
n = n.nextSibling().toElement();
}
}
if ( no_pixmaps && pal == QPalette( pal.active().button(), pal.active().background() ) ) {
v = "QPalette( QColor( %1, %2, %3 ), QColor( %1, %2, %3 ) )";
示例2: elementToVariant
/*!
Interprets element \a e as variant and returns the result of the interpretation.
*/
QVariant DomTool::elementToVariant( const QDomElement& e, const QVariant& defValue, QString &comment )
{
QVariant v;
if ( e.tagName() == "rect" ) {
QDomElement n3 = e.firstChild().toElement();
int x = 0, y = 0, w = 0, h = 0;
while ( !n3.isNull() ) {
if ( n3.tagName() == "x" )
x = n3.firstChild().toText().data().toInt();
else if ( n3.tagName() == "y" )
y = n3.firstChild().toText().data().toInt();
else if ( n3.tagName() == "width" )
w = n3.firstChild().toText().data().toInt();
else if ( n3.tagName() == "height" )
h = n3.firstChild().toText().data().toInt();
n3 = n3.nextSibling().toElement();
}
v = QVariant( QRect( x, y, w, h ) );
} else if ( e.tagName() == "point" ) {
QDomElement n3 = e.firstChild().toElement();
int x = 0, y = 0;
while ( !n3.isNull() ) {
if ( n3.tagName() == "x" )
x = n3.firstChild().toText().data().toInt();
else if ( n3.tagName() == "y" )
y = n3.firstChild().toText().data().toInt();
n3 = n3.nextSibling().toElement();
}
v = QVariant( QPoint( x, y ) );
} else if ( e.tagName() == "size" ) {
QDomElement n3 = e.firstChild().toElement();
int w = 0, h = 0;
while ( !n3.isNull() ) {
if ( n3.tagName() == "width" )
w = n3.firstChild().toText().data().toInt();
else if ( n3.tagName() == "height" )
h = n3.firstChild().toText().data().toInt();
n3 = n3.nextSibling().toElement();
}
v = QVariant( QSize( w, h ) );
} else if ( e.tagName() == "color" ) {
v = QVariant( readColor( e ) );
} else if ( e.tagName() == "font" ) {
QDomElement n3 = e.firstChild().toElement();
QFont f( defValue.toFont() );
while ( !n3.isNull() ) {
if ( n3.tagName() == "family" )
f.setFamily( n3.firstChild().toText().data() );
else if ( n3.tagName() == "pointsize" )
f.setPointSize( n3.firstChild().toText().data().toInt() );
else if ( n3.tagName() == "bold" )
f.setBold( n3.firstChild().toText().data().toInt() );
else if ( n3.tagName() == "italic" )
f.setItalic( n3.firstChild().toText().data().toInt() );
else if ( n3.tagName() == "underline" )
f.setUnderline( n3.firstChild().toText().data().toInt() );
else if ( n3.tagName() == "strikeout" )
f.setStrikeOut( n3.firstChild().toText().data().toInt() );
n3 = n3.nextSibling().toElement();
}
v = QVariant( f );
} else if ( e.tagName() == "string" ) {
v = QVariant( e.firstChild().toText().data() );
QDomElement n = e;
n = n.nextSibling().toElement();
if ( n.tagName() == "comment" )
comment = n.firstChild().toText().data();
} else if ( e.tagName() == "cstring" ) {
v = QVariant( QCString( e.firstChild().toText().data() ) );
} else if ( e.tagName() == "number" ) {
bool ok = TRUE;
v = QVariant( e.firstChild().toText().data().toInt( &ok ) );
if ( !ok )
v = QVariant( e.firstChild().toText().data().toDouble() );
} else if ( e.tagName() == "bool" ) {
QString t = e.firstChild().toText().data();
v = QVariant( t == "true" || t == "1", 0 );
} else if ( e.tagName() == "pixmap" ) {
v = QVariant( e.firstChild().toText().data() );
} else if ( e.tagName() == "iconset" ) {
v = QVariant( e.firstChild().toText().data() );
} else if ( e.tagName() == "image" ) {
v = QVariant( e.firstChild().toText().data() );
} else if ( e.tagName() == "enum" ) {
v = QVariant( e.firstChild().toText().data() );
} else if ( e.tagName() == "set" ) {
v = QVariant( e.firstChild().toText().data() );
} else if ( e.tagName() == "sizepolicy" ) {
QDomElement n3 = e.firstChild().toElement();
QSizePolicy sp;
while ( !n3.isNull() ) {
if ( n3.tagName() == "hsizetype" )
sp.setHorData( (QSizePolicy::SizeType)n3.firstChild().toText().data().toInt() );
else if ( n3.tagName() == "vsizetype" )
sp.setVerData( (QSizePolicy::SizeType)n3.firstChild().toText().data().toInt() );
else if ( n3.tagName() == "horstretch" )
sp.setHorStretch( n3.firstChild().toText().data().toInt() );
//.........这里部分代码省略.........
示例3: elementToVariant
//.........这里部分代码省略.........
#endif
ok = true;
}
}
else if (e.tagName() == "font")
{
QFont f;
bool boolOk;
if (e.hasAttribute("family"))
f.setFamily(e.attribute("family"));
if (e.hasAttribute("pointsize"))
f.setPointSize(e.attribute("pointsize").toInt());
if (e.hasAttribute("bold"))
f.setBold(getBoolFromString(e.attribute("bold"), boolOk));
if (e.hasAttribute("italic"))
f.setItalic(getBoolFromString(e.attribute("italic"), boolOk));
if (e.hasAttribute("strikeout"))
f.setStrikeOut(getBoolFromString(e.attribute("strikeout"), boolOk));
v = QVariant(f);
ok = true;
}
else if (e.tagName() == "sizepolicy")
{
QSizePolicy sp;
if (e.hasAttribute("hsizetype"))
sp.setHorData((QSizePolicy::SizeType)e.attribute("hsizetype").toInt());
if (e.hasAttribute("vsizetype"))
sp.setVerData((QSizePolicy::SizeType)e.attribute("vsizetype").toInt());
#if (QT_VERSION >= 300)
if (e.hasAttribute("horstretch"))
sp.setHorStretch(e.attribute("horstretch").toInt());
if (e.hasAttribute("verstretch"))
sp.setHorStretch(e.attribute("verstretch").toInt());
#endif
v = QVariant(sp);
ok = true;
}
else if (e.tagName() == "cursor")
{
if (e.hasAttribute("shape"))
v = QVariant(QCursor(e.attribute("shape").toInt(&ok, 10)));
else
qWarning("%s element without value!", (const char*)e.tagName());
}
else if (e.tagName() == "stringlist")
{
QDomNodeList stringNodeList = e.elementsByTagName("string");
QStringList stringList;
QDomElement stringElement;
for (uint i = 0; i < stringNodeList.length(); i++)
{
stringElement = stringNodeList.item(i).toElement();
if (!stringElement.hasAttribute("value"))
{
qWarning("%s element in %s without value! Ignoring!",
(const char*)stringElement.tagName(),
(const char*)e.tagName());
continue;
}
stringList.append(e.attribute("value"));
}
示例4: elementToVariant
//.........这里部分代码省略.........
else if (e.tagName() == "key")
{
int key;
if (e.hasAttribute("sequence"))
{
key = QAccel::stringToKey(e.attribute("sequence"));
// fix the key code (deal with Qt brain death)
key &= ~Qt::UNICODE_ACCEL;
#if QT_VERSION >= 300
v = QVariant(QKeySequence(key));
#else
v = QVariant(key);
#endif
ok = true;
}
}
else if (e.tagName() == "font")
{
QFont f;
bool boolOk;
if (e.hasAttribute("family"))
f.setFamily(e.attribute("family"));
if (e.hasAttribute("pointsize"))
f.setPointSize(e.attribute("pointsize").toInt());
if (e.hasAttribute("bold"))
f.setBold(getBoolFromString(e.attribute("bold"), boolOk));
if (e.hasAttribute("italic"))
f.setItalic(getBoolFromString(e.attribute("italic"), boolOk));
if (e.hasAttribute("strikeout"))
f.setStrikeOut(getBoolFromString(e.attribute("strikeout"), boolOk));
v = QVariant(f);
ok = true;
}
else if (e.tagName() == "sizepolicy")
{
QSizePolicy sp;
if (e.hasAttribute("hsizetype"))
sp.setHorData((QSizePolicy::SizeType)e.attribute("hsizetype").toInt());
if (e.hasAttribute("vsizetype"))
sp.setVerData((QSizePolicy::SizeType)e.attribute("vsizetype").toInt());
#if (QT_VERSION >= 300)
if (e.hasAttribute("horstretch"))
sp.setHorStretch(e.attribute("horstretch").toInt());
if (e.hasAttribute("verstretch"))
sp.setHorStretch(e.attribute("verstretch").toInt());
#endif
v = QVariant(sp);
ok = true;
}
else if (e.tagName() == "cursor")
{
if (e.hasAttribute("shape"))
v = QVariant(QCursor(e.attribute("shape").toUInt(&ok, 10)));
else
qWarning("%s element without value!", (const char*)e.tagName());
}
else if (e.tagName() == "stringlist")
{
QDomNodeList stringNodeList = e.elementsByTagName("string");
QStringList stringList;
QDomElement stringElement;
for (uint i = 0; i < stringNodeList.length(); i++)
{
stringElement = stringNodeList.item(i).toElement();
if (!stringElement.hasAttribute("value"))
{
qWarning("%s element in %s without value! Ignoring!",
(const char*)stringElement.tagName(),
(const char*)e.tagName());
continue;
}
stringList.append(e.attribute("value"));
}
v = stringList;
ok = true;
}
else if (e.tagName() == "list")
{
qWarning("Unimplemented tag: %s", (const char*)e.tagName());
}
else if (e.tagName() == "map")
{
qWarning("Unimplemented tag: %s", (const char*)e.tagName());
}
else
{
qWarning("Unknown tag: %s", (const char*)e.tagName());
}
return ok;
}