本文整理汇总了C++中QVariant::toRect方法的典型用法代码示例。如果您正苦于以下问题:C++ QVariant::toRect方法的具体用法?C++ QVariant::toRect怎么用?C++ QVariant::toRect使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QVariant
的用法示例。
在下文中一共展示了QVariant::toRect方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: setProperty
void QCupsPrintEngine::setProperty(PrintEnginePropertyKey key, const QVariant &value)
{
Q_D(QCupsPrintEngine);
switch (int(key)) {
case PPK_PaperSize:
d->printerPaperSize = QPrinter::PaperSize(value.toInt());
d->setPaperSize();
break;
case PPK_CupsPageRect:
d->cupsPageRect = value.toRect();
break;
case PPK_CupsPaperRect:
d->cupsPaperRect = value.toRect();
break;
case PPK_CupsOptions:
d->cupsOptions = value.toStringList();
break;
case PPK_CupsStringPageSize:
d->cupsStringPageSize = value.toString();
break;
case PPK_PrinterName:
// prevent setting the defaults again for the same printer
if (d->printerName != value.toString()) {
d->printerName = value.toString();
d->setCupsDefaults();
}
break;
default:
QPdfPrintEngine::setProperty(key, value);
break;
}
}
示例2: switch
void LabelPrintEngine::setProperty ( PrintEnginePropertyKey key, const QVariant & value )
{
switch(key) {
case QPrintEngine::PPK_PrinterName:
m_printerName = value.toString();
break;
case QPrintEngine::PPK_DocumentName:
m_docName = value.toString();
break;
case QPrintEngine::PPK_CustomPaperSize:
m_paperSize = value.toSizeF();
m_paperRect = QRect(QPoint(0,0),m_paperSize.toSize());
break;
case QPrintEngine::PPK_PaperRect:
case QPrintEngine::PPK_PageRect:
m_paperSize = value.toRect().size();
m_paperRect = value.toRect();
break;
case QPrintEngine::PPK_PageSize:
// not implemented
break;
case QPrintEngine::PPK_Resolution:
m_resolution = value.toInt();
break;
default: break;
}
}
示例3: updateCurrentValue
void DummyAnimation::updateCurrentValue(const QVariant &value)
{
if (state() == Stopped)
return;
if (m_dummy)
m_dummy->setRect(value.toRect());
}
示例4: setProperty
void HappyPropertySheetExtension::setProperty(int index, const QVariant &value)
{
if ( index == 0 )
{
m_widget->setObjectName( value.toString() );
}
else if ( index == 1 )
{
m_widget->setGeometry( value.toRect() );
}
else if ( index == 2 )
{
m_widget->setDiameterInPixels( value.toInt() );
}
else if ( index == 3 )
{
m_widget->setColour( value.toString() );
}
else if ( index == 4 )
{
// m_widget->setScalpHair( value.value<ImaginativeThinking::Hair>() );
}
else if ( index == 5 )
{
// m_widget->setScalpHair( value.value<ImaginativeThinking::Hair>() );
}
}
示例5: init
/*!
* Initialisation du module
*
*/
void CRaspiGPIO::init(CApplication *application)
{
CModule::init(application);
setGUI(&m_ihm); // indique à la classe de base l'IHM
// Gère les actions sur clic droit sur le panel graphique du module
m_ihm.setContextMenuPolicy(Qt::CustomContextMenu);
connect(&m_ihm, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(onRightClicGUI(QPoint)));
// Restore la taille de la fenêtre
QVariant val;
val = m_application->m_eeprom->read(getName(), "geometry", QRect(50, 50, 150, 150));
m_ihm.setGeometry(val.toRect());
// Restore le fait que la fenêtre est visible ou non
val = m_application->m_eeprom->read(getName(), "visible", QVariant(true));
if (val.toBool()) { m_ihm.show(); }
else { m_ihm.hide(); }
// Restore le niveau d'affichage
val = m_application->m_eeprom->read(getName(), "niveau_trace", QVariant(MSG_TOUS));
setNiveauTrace(val.toUInt());
// Restore la couleur de fond
val = m_application->m_eeprom->read(getName(), "background_color", QVariant(DEFAULT_MODULE_COLOR));
setBackgroundColor(val.value<QColor>());
wiringPiSetupGpio(); // Utilise la numérotation de pin BCM
for (unsigned int i=0; i<MAX_GPIO_COUNT; i++) {
// Recherche dans le fichier EEPROM une configuration de type "gpio_<i>=input pull down"
// gpio_17 = input
QString eeprom_config_name = "gpio_" + QString::number(i);
val = m_application->m_eeprom->read(getName(), eeprom_config_name, QVariant());
if (val != QVariant()) { // le paramètre a été trouvé -> le GPIO est utilisé et doit être configuré
configPinMode(i, val.toString());
}
// Initialise la liste des GPIO dans la liste déroulante de configuration
// on part des contrôles affichés sur l'interface et on récupère les numéros
// Rensigne dans la liste déroulante des GPIO tous les numéros possibles de GPIO
QLabel *lbl = m_ihm.findChild<QLabel*>(PREFIX_MODE_GPIO + QString::number(i)); // "mode_GPIO_<i>" c'est le nom de tous les labels des GPIO sur l'IHM pour indiquer si c'est une entrée / sortie / ...
if (lbl) {
m_ihm.ui.configChoixGPIO->addItem("GPIO " + QString::number(i));
}
// connexion signal/slot avec toutes les checkbox qui permettent d'écrire sur le port
// on repert toutes les checkbox par leur nom "write_GPIO_<i>"
QCheckBox *checkbox = m_ihm.findChild<QCheckBox*>(PREFIX_CHECKBOX_WRITE + QString::number(i));
if (checkbox) {
connect(checkbox, SIGNAL(clicked(bool)), this, SLOT(onWritePinChange(bool)));
}
}
// Renseigne dans la liste déroulante des configurations possibles
QStringList list_modes;
list_modes << "" << "Input" << "Input pull down" << "Input pull up" << "Output" << "PWM Output";
m_ihm.ui.configChoixMode->addItems(list_modes);
connect(m_ihm.ui.configChoixGPIO, SIGNAL(activated(int)), this, SLOT(onChoixConfigGPIO()));
connect(m_ihm.ui.configChoixMode, SIGNAL(activated(QString)), this, SLOT(onChoixConfigMode(QString)));
connect(&m_timer_read, SIGNAL(timeout()), this, SLOT(readAllInputs()));
m_timer_read.start(100);
}
示例6: inputMethodQuery
/*!
\internal
Reimplemented from QGraphicsItemPrivate. ### Qt 5: Move impl to
reimplementation QGraphicsProxyWidget::inputMethodQuery().
*/
QVariant QGraphicsProxyWidgetPrivate::inputMethodQueryHelper(Qt::InputMethodQuery query) const
{
Q_Q(const QGraphicsProxyWidget);
if (!widget || !q->hasFocus())
return QVariant();
QWidget *focusWidget = widget->focusWidget();
if (!focusWidget)
focusWidget = widget;
QVariant v = focusWidget->inputMethodQuery(query);
QPointF focusWidgetPos = q->subWidgetRect(focusWidget).topLeft();
switch (v.type()) {
case QVariant::RectF:
v = v.toRectF().translated(focusWidgetPos);
break;
case QVariant::PointF:
v = v.toPointF() + focusWidgetPos;
break;
case QVariant::Rect:
v = v.toRect().translated(focusWidgetPos.toPoint());
break;
case QVariant::Point:
v = v.toPoint() + focusWidgetPos.toPoint();
break;
default:
break;
}
return v;
}
示例7: setValue
void QRectProperty::setValue(const QVariant &value)
{
disconnectUpdateValue();
QRect re = value.toRect();
if(m_x->getVisible())
{
m_x->setValue(re.x());
m_y->setValue(re.y());
}
else
{
m_x->setValue(0);
m_y->setValue(0);
}
m_width->setValue(re.width());
m_height->setValue(re.height());
re.setRect(m_x->getValue().toInt(),m_y->getValue().toInt(),
m_width->getValue().toInt(),m_height->getValue().toInt());
connectUpdateValue();
QAbstractProperty::setValue(re);
}
示例8: init
/**
* Main initialization function
*/
void App::init()
{
QSettings settings;
setWindowIcon(QIcon(":/qlc.png"));
#ifndef __APPLE__
/* MDI Area */
setCentralWidget(new QMdiArea(this));
centralWidget()->setContextMenuPolicy(Qt::CustomContextMenu);
connect(centralWidget(),
SIGNAL(customContextMenuRequested(const QPoint&)),
this,
SLOT(slotCustomContextMenuRequested(const QPoint&)));
/* Workspace background */
setBackgroundImage(settings.value("/workspace/background").toString());
/* Application geometry and window state */
QVariant var;
var = settings.value(KXMLQLCGeometry, QRect(0, 0, 800, 600));
if (var.isValid() == true)
setGeometry(var.toRect());
var = settings.value(KXMLQLCWindowState, Qt::WindowNoState);
if (var.isValid() == true)
setWindowState(Qt::WindowState(var.toInt()));
#else
/* App is just a toolbar, we only need it to be the size of the
toolbar's buttons */
resize(600, 32);
move(0, 22);
#endif
/* Input & output mappers and their plugins */
initOutputMap();
initInputMap();
/* Function running engine/master timer */
m_masterTimer = new MasterTimer(this, m_outputMap);
m_masterTimer->start();
/* Buses */
Bus::init(this);
/* Fixture definitions */
loadFixtureDefinitions();
// The main view
initStatusBar();
initActions();
initMenuBar();
initToolBar();
// Document
initDoc();
// Start up in non-modified state
m_doc->resetModified();
}
示例9: plot
/**
* Plot with plotter, using the painter.
* To be called from QML
*/
void Calculator::plot(QVariant painter, const QVariant plotArea)
{
QPainter * thePainter;
uint uintPainter = painter.toUInt();
thePainter = (QPainter *)uintPainter;
QRect thePlotArea = plotArea.toRect();
plotter.plot(thePainter, thePlotArea);
}
示例10: displayText
QString RectDelegate::displayText( const QVariant& value ) const
{
const QRect r(value.toRect());
return QString::fromLatin1(RECTEDIT_MASK)
.arg(r.x())
.arg(r.y())
.arg(r.width())
.arg(r.height());
}
示例11: setValue
void RectComposedProperty::setValue(Property *property,
const QVariant &value, bool rememberOldValue)
{
const QRect r( value.toRect() );
property->child("x")->setValue(r.x(), rememberOldValue, false);
property->child("y")->setValue(r.y(), rememberOldValue, false);
property->child("width")->setValue(r.width(), rememberOldValue, false);
property->child("height")->setValue(r.height(), rememberOldValue, false);
}
示例12: write
QString write(const QVariant &variant)
{
if (!variant.isValid()) {
qWarning() << "Trying to serialize invalid QVariant";
return QString();
}
QString value;
switch (variant.type()) {
case QMetaType::QPoint:
{
QPoint p = variant.toPoint();
value = QString("%1,%2").arg(QString::number(p.x()), QString::number(p.y()));
break;
}
case QMetaType::QPointF:
{
QPointF p = variant.toPointF();
value = QString("%1,%2").arg(QString::number(p.x(), 'f'), QString::number(p.y(), 'f'));
break;
}
case QMetaType::QSize:
{
QSize s = variant.toSize();
value = QString("%1x%2").arg(QString::number(s.width()), QString::number(s.height()));
break;
}
case QMetaType::QSizeF:
{
QSizeF s = variant.toSizeF();
value = QString("%1x%2").arg(QString::number(s.width(), 'f'), QString::number(s.height(), 'f'));
break;
}
case QMetaType::QRect:
{
QRect r = variant.toRect();
value = QString("%1,%2,%3x%4").arg(QString::number(r.x()), QString::number(r.y()),
QString::number(r.width()), QString::number(r.height()));
break;
}
case QMetaType::QRectF:
{
QRectF r = variant.toRectF();
value = QString("%1,%2,%3x%4").arg(QString::number(r.x(), 'f'), QString::number(r.y(), 'f'),
QString::number(r.width(), 'f'), QString::number(r.height(), 'f'));
break;
}
default:
QVariant strVariant = variant;
strVariant.convert(QVariant::String);
if (!strVariant.isValid())
qWarning() << Q_FUNC_INFO << "cannot serialize type " << QMetaType::typeName(variant.type());
value = strVariant.toString();
}
return value;
}
示例13: setOption
void QSvgIOHandler::setOption(ImageOption option, const QVariant & value)
{
switch(option) {
case ClipRect:
d->clipRect = value.toRect();
break;
case ScaledSize:
d->scaledSize = value.toSize();
break;
case ScaledClipRect:
d->scaledClipRect = value.toRect();
break;
case BackgroundColor:
d->backColor = value.value<QColor>();
break;
default:
break;
}
}
示例14: QMainWindow
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
QSettings settings;
QVariant val = settings.value("Geometry",
QRect(50, 50, 200, 200));
setGeometry(val.toRect());
}
示例15: displayText
QString VariantDelegate::displayText(const QVariant &value)
{
switch (value.type()) {
case QVariant::Bool:
case QVariant::ByteArray:
case QVariant::Char:
case QVariant::Double:
case QVariant::Int:
case QVariant::LongLong:
case QVariant::String:
case QVariant::UInt:
case QVariant::ULongLong:
return value.toString();
case QVariant::Color:
{
QColor color = qvariant_cast<QColor>(value);
return QString("(%1,%2,%3,%4)")
.arg(color.red()).arg(color.green())
.arg(color.blue()).arg(color.alpha());
}
case QVariant::Date:
return value.toDate().toString(Qt::ISODate);
case QVariant::DateTime:
return value.toDateTime().toString(Qt::ISODate);
case QVariant::Invalid:
return "<Invalid>";
case QVariant::Point:
{
QPoint point = value.toPoint();
return QString("(%1,%2)").arg(point.x()).arg(point.y());
}
case QVariant::Rect:
{
QRect rect = value.toRect();
return QString("(%1,%2,%3,%4)")
.arg(rect.x()).arg(rect.y())
.arg(rect.width()).arg(rect.height());
}
case QVariant::Size:
{
QSize size = value.toSize();
return QString("(%1,%2)").arg(size.width()).arg(size.height());
}
case QVariant::StringList:
return value.toStringList().join(',');
case QVariant::Time:
return value.toTime().toString(Qt::ISODate);
default:
break;
}
return QString("<%1>").arg(value.typeName());
}