本文整理汇总了C++中QVariant::toSizePolicy方法的典型用法代码示例。如果您正苦于以下问题:C++ QVariant::toSizePolicy方法的具体用法?C++ QVariant::toSizePolicy怎么用?C++ QVariant::toSizePolicy使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QVariant
的用法示例。
在下文中一共展示了QVariant::toSizePolicy方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: if
void
SizePolicyCustomProperty::setValue(const QVariant &value, bool rememberOldValue)
{
if(!m_property)
return;
if(m_property->parent()) {
QSizePolicy v = m_property->parent()->value().toSizePolicy();
if(m_property->type() == SizePolicy_HorData)
v.setHorData(QSizePolicy::SizeType(value.toInt()));
else if(m_property->type() == SizePolicy_VerData)
v.setVerData(QSizePolicy::SizeType(value.toInt()));
else if(m_property->type() == SizePolicy_HorStretch)
v.setHorStretch(value.toInt());
else if(m_property->type() == SizePolicy_VerStretch)
v.setVerStretch(value.toInt());
m_property->parent()->setValue(v, true, false);
}
else {
QSizePolicy v = value.toSizePolicy();
m_property->child("hSizeType")->setValue(v.horData(), rememberOldValue, false);
m_property->child("vSizeType")->setValue(v.verData(), rememberOldValue, false);
m_property->child("hStretch")->setValue(v.horStretch(), rememberOldValue, false);
m_property->child("vStretch")->setValue(v.verStretch(), rememberOldValue, false);
}
}
示例2: setValue
void PSizePolicyEdit::setValue(const QVariant& value, bool emitChange)
{
m_value = value;
m_edit->setText(QString("%1/%2/%3/%4").arg(findValueDescription(value.toSizePolicy().horData())).arg(findValueDescription(value.toSizePolicy().verData())).arg(value.toSizePolicy().horStretch()).arg(value.toSizePolicy().verStretch()));
if (emitChange)
emit propertyChanged(m_property, value);
}
示例3: variantToElement
//.........这里部分代码省略.........
case QVariant::Rect:
{
e.setTagName("rect");
QRect rect = v.toRect();
e.setAttribute("x", rect.x());
e.setAttribute("y", rect.y());
e.setAttribute("width", rect.width());
e.setAttribute("height", rect.height());
}
break;
case QVariant::Size:
{
e.setTagName("size");
QSize qsize = v.toSize();
e.setAttribute("width", qsize.width());
e.setAttribute("height", qsize.height());
}
break;
case QVariant::Font:
{
e.setTagName("font");
QFont f(v.toFont());
e.setAttribute("family", f.family());
e.setAttribute("pointsize", f.pointSize());
e.setAttribute("bold", boolString(f.bold()));
e.setAttribute("italic", boolString(f.italic()));
e.setAttribute("underline", boolString(f.underline()));
e.setAttribute("strikeout", boolString(f.strikeOut()));
}
break;
case QVariant::SizePolicy:
{
e.setTagName("sizepolicy");
QSizePolicy sp(v.toSizePolicy());
e.setAttribute("hsizetype", sp.horData());
e.setAttribute("vsizetype", sp.verData());
#if (QT_VERSION >= 300)
e.setAttribute("horstretch", sp.horStretch());
e.setAttribute("verstretch", sp.verStretch());
#endif
}
break;
case QVariant::Cursor:
e.setTagName("cursor");
e.setAttribute("shape", v.toCursor().shape());
break;
case QVariant::StringList:
{
e.setTagName("stringlist");
uint j;
QDomNode n;
QDomNodeList stringNodeList = e.elementsByTagName("string");
QDomElement stringElem;
QStringList stringList = v.toStringList();
QStringList::Iterator it = stringList.begin();
for (j = 0;
((j < stringNodeList.length()) && (it != stringList.end()));
j++)
{
// get the current string element
stringElem = stringNodeList.item(j).toElement();
// set it to the current string
示例4: drawViewer
void PSizePolicyEdit::drawViewer(QPainter* p, const QColorGroup& cg, const QRect& r, const QVariant& value)
{
p->setPen(Qt::NoPen);
p->setBrush(cg.background());
p->drawRect(r);
p->drawText(r, Qt::AlignLeft | Qt::AlignVCenter | Qt::SingleLine, QString("%1/%2/%3/%4").arg(findValueDescription(value.toSizePolicy().horData())).arg(findValueDescription(value.toSizePolicy().verData())).arg(value.toSizePolicy().horStretch()).arg(value.toSizePolicy().verStretch()));
}
示例5: process
//.........这里部分代码省略.........
for(uint i= 1; i < st.count(); i++)t+='/'+st.at(i);
att2->setText(1,t);
}
else if(val.type() == QVariant::String)att2->setText(1,'"'+val.toString()+'"');
else if(val.type() == QVariant::CString)att2->setText(1,'"'+val.toCString()+'"');
else if(val.type() == QVariant::Bool){
if(val.toBool())att2->setText(1,"True");
else att2->setText(1,"False");
}
else if(val.type() == QVariant::Int)att2->setText(1,QString::number(val.toInt()));
else if(val.type() == QVariant::UInt)att2->setText(1,QString::number(val.toUInt()));
else if(val.type() == QVariant::Double)att2->setText(1,QString::number(val.toDouble()));
else if(val.type() == QVariant::Rect){
const QRect r = val.toRect();
att2->setText(1,'[' + QString::number(r.left()) + ',' + QString::number(r.top())+
',' + QString::number(r.right()) + ',' + QString::number(r.bottom())+']');
}
else if(val.type() == QVariant::Region){
const QRegion reg = val.toRegion();
QRect r = reg.boundingRect();
att2->setText(1,'[' + QString::number(r.left()) + ',' + QString::number(r.top())+
',' + QString::number(r.right()) + ',' + QString::number(r.bottom())+"],");
}
else if(val.type() == QVariant::Size){
const QSize s = val.toSize();
att2->setText(1,'[' + QString::number(s.width()) + ',' + QString::number(s.height())+']');
}
else if(val.type() == QVariant::Point){
const QPoint p = val.toPoint();
att2->setText(1,'[' + QString::number(p.x()) + ',' + QString::number(p.y())+']');
}
else if(val.type() == QVariant::Color){
const QColor c = val.toColor();
att2->setText(1,'[' + QString::number(c.red()) + ',' +
QString::number(c.green()) + ',' +
QString::number(c.blue()) + ']');
}
else if(val.type() == QVariant::ColorGroup){
const QColorGroup cg = val.toColorGroup();
QColor c = cg.base();
att2->setText(1,'[' + QString::number(c.red()) + ',' +
QString::number(c.green()) + ',' +
QString::number(c.blue()) + "], ...");
}
else if(val.type() == QVariant::Font){
const QFont f = val.toFont();
QString text = '\'' + f.family() + "', " + QString::number(f.pointSize())
+ ", " + QString::number(f.weight());
if(f.italic())text+=", italic";
att2->setText(1,text);
}
else if(val.type() == QVariant::SizePolicy){
QSizePolicy sp = val.toSizePolicy();
QString text;
if(sp.horData() == QSizePolicy::Fixed)text+="Fixed";
else if(sp.horData() == QSizePolicy::Minimum )text+="Minimum";
else if(sp.horData() == QSizePolicy::Maximum )text+="Maximum";
else if(sp.horData() == QSizePolicy::Preferred )text+="Preferred";
else if(sp.horData() == QSizePolicy::MinimumExpanding )text+="MinimumExpanding";
else if(sp.horData() == QSizePolicy::Expanding )text+="Expanding";
text +='/';
if(sp.verData() == QSizePolicy::Fixed)text+="Fixed";
else if(sp.verData() == QSizePolicy::Minimum )text+="Minimum";
else if(sp.verData() == QSizePolicy::Maximum )text+="Maximum";
else if(sp.verData() == QSizePolicy::Preferred )text+="Preferred";
else if(sp.verData() == QSizePolicy::MinimumExpanding )text+="MinimumExpanding";
else if(sp.verData() == QSizePolicy::Expanding )text+="Expanding";
att2->setText(1,text);
}
else if(val.type() == QVariant::Pixmap){
QPixmap pix = val.toPixmap();
if(!pix.isNull())att2->setPixmap(1,pix);
}
else if(val.type() == QVariant::Cursor){
const QCursor cur = val.toCursor();
const QBitmap * pix = cur.bitmap();
if(pix && !pix->isNull())att2->setPixmap(1,*pix);
else att2->setText(1,QString::number(cur.shape()));
}
}
}
}
const QObjectList * roots = obj->children();
if(roots != NULL){
__current = new QListViewItem(__current,att,"children","ptr="+QString::number((unsigned long)roots),
"List<QObject>["+QString::number(roots->count())+"]");
__current->setPixmap(0,__pixappe);
QObjectList r(*roots);
uint size = r.count();
for(uint i = 0; i < size; i++ ){
QObject * _obj = r.at(i);
process(_obj);
}
}
__current = buf;
}
}
示例6: variantToElement
bool DomConvenience::variantToElement(const QVariant& v, QDomElement& e)
{
bool ok = true;
clearAttributes(e);
switch (v.type())
{
case QVariant::String:
e.setTagName("string");
e.setAttribute("value", v.toString().utf8());
break;
case QVariant::CString:
e.setTagName("string");
e.setAttribute("value", v.toCString());
break;
case QVariant::Int:
e.setTagName("int");
e.setAttribute("value", v.toInt());
break;
case QVariant::UInt:
e.setTagName("uint");
e.setAttribute("value", v.toUInt());
break;
case QVariant::Double:
e.setTagName("double");
e.setAttribute("value", v.toDouble());
break;
case QVariant::Bool:
e.setTagName("bool");
e.setAttribute("value", boolString(v.toBool()));
break;
case QVariant::Color:
{
e.setTagName("color");
QColor color = v.toColor();
e.setAttribute("red", color.red());
e.setAttribute("green", color.green());
e.setAttribute("blue", color.blue());
}
break;
case QVariant::Point:
{
e.setTagName("point");
QPoint point = v.toPoint();
e.setAttribute("x", point.x());
e.setAttribute("y", point.y());
}
break;
case QVariant::Rect:
{
e.setTagName("rect");
QRect rect = v.toRect();
e.setAttribute("x", rect.x());
e.setAttribute("y", rect.y());
e.setAttribute("width", rect.width());
e.setAttribute("height", rect.height());
}
break;
case QVariant::Size:
{
e.setTagName("size");
QSize qsize = v.toSize();
e.setAttribute("width", qsize.width());
e.setAttribute("height", qsize.height());
}
break;
case QVariant::Font:
{
e.setTagName("font");
QFont f(v.toFont());
e.setAttribute("family", f.family());
e.setAttribute("pointsize", f.pointSize());
e.setAttribute("bold", boolString(f.bold()));
e.setAttribute("italic", boolString(f.italic()));
e.setAttribute("underline", boolString(f.underline()));
e.setAttribute("strikeout", boolString(f.strikeOut()));
}
break;
case QVariant::SizePolicy:
{
e.setTagName("sizepolicy");
QSizePolicy sp(v.toSizePolicy());
e.setAttribute("hsizetype", sp.horData());
e.setAttribute("vsizetype", sp.verData());
#if (QT_VERSION >= 300)
e.setAttribute("horstretch", sp.horStretch());
e.setAttribute("verstretch", sp.verStretch());
#endif
}
break;
case QVariant::Cursor:
e.setTagName("cursor");
e.setAttribute("shape", v.toCursor().shape());
break;
case QVariant::StringList:
{
e.setTagName("stringlist");
uint j;
//.........这里部分代码省略.........