本文整理汇总了C++中QMimeData::colorData方法的典型用法代码示例。如果您正苦于以下问题:C++ QMimeData::colorData方法的具体用法?C++ QMimeData::colorData怎么用?C++ QMimeData::colorData使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QMimeData
的用法示例。
在下文中一共展示了QMimeData::colorData方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: colorData
void tst_QMimeData::colorData() const
{
QMimeData mimeData;
QColor red = Qt::red;
QColor blue = Qt::blue;
// set, verify
mimeData.setColorData(red);
QVERIFY(mimeData.hasColor());
QCOMPARE(qvariant_cast<QColor>(mimeData.colorData()), red);
// change, verify
mimeData.setColorData(QColor(Qt::blue));
QVERIFY(mimeData.hasColor());
QCOMPARE(qvariant_cast<QColor>(mimeData.colorData()), blue);
}
示例2:
/*
* This function is called when a standalone MimeData instance is passed as parameter to push()
*/
QMimeData *QQuickMimeData::toMimeData()
{
QMimeData *ret = m_mimeData;
if (!m_refData) {
m_mimeData = new QMimeData;
// copy data so we keep the properties as they were
Q_FOREACH(const QString &format, ret->formats()) {
m_mimeData->setData(format, ret->data(format));
}
// set teh color separately
m_mimeData->setColorData(ret->colorData());
}
示例3:
QDebug operator<<(QDebug d, const QMimeData &m)
{
QDebug nospace = d.nospace();
const QStringList formats = m.formats();
nospace << "QMimeData: " << formats.join(QStringLiteral(", ")) << '\n'
<< " Text=" << m.hasText() << " HTML=" << m.hasHtml()
<< " Color=" << m.hasColor() << " Image=" << m.hasImage()
<< " URLs=" << m.hasUrls() << '\n';
if (m.hasText())
nospace << " Text: '" << m.text() << "'\n";
if (m.hasHtml())
nospace << " HTML: '" << m.html() << "'\n";
if (m.hasColor())
nospace << " Color: " << qvariant_cast<QColor>(m.colorData()) << '\n';
if (m.hasImage())
nospace << " Image: " << qvariant_cast<QImage>(m.imageData()).size() << '\n';
if (m.hasUrls())
nospace << " URLs: " << m.urls() << '\n';
return d;
}