本文整理汇总了C++中QStandardItem::clone方法的典型用法代码示例。如果您正苦于以下问题:C++ QStandardItem::clone方法的具体用法?C++ QStandardItem::clone怎么用?C++ QStandardItem::clone使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QStandardItem
的用法示例。
在下文中一共展示了QStandardItem::clone方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: clone
void tst_QStandardItem::clone()
{
QStandardItem item;
item.setText(QLatin1String("text"));
item.setToolTip(QLatin1String("toolTip"));
item.setStatusTip(QLatin1String("statusTip"));
item.setWhatsThis(QLatin1String("whatsThis"));
item.setSizeHint(QSize(64, 48));
item.setFont(QFont());
item.setTextAlignment(Qt::AlignLeft|Qt::AlignVCenter);
item.setBackground(QColor(Qt::blue));
item.setForeground(QColor(Qt::green));
item.setCheckState(Qt::PartiallyChecked);
item.setAccessibleText(QLatin1String("accessibleText"));
item.setAccessibleDescription(QLatin1String("accessibleDescription"));
item.setFlags(Qt::ItemIsEnabled | Qt::ItemIsDropEnabled);
QStandardItem *clone = item.clone();
QCOMPARE(clone->text(), item.text());
QCOMPARE(clone->toolTip(), item.toolTip());
QCOMPARE(clone->statusTip(), item.statusTip());
QCOMPARE(clone->whatsThis(), item.whatsThis());
QCOMPARE(clone->sizeHint(), item.sizeHint());
QCOMPARE(clone->font(), item.font());
QCOMPARE(clone->textAlignment(), item.textAlignment());
QCOMPARE(clone->background(), item.background());
QCOMPARE(clone->foreground(), item.foreground());
QCOMPARE(clone->checkState(), item.checkState());
QCOMPARE(clone->accessibleText(), item.accessibleText());
QCOMPARE(clone->accessibleDescription(), item.accessibleDescription());
QCOMPARE(clone->flags(), item.flags());
QVERIFY(!(*clone < item));
delete clone;
}
示例2: dropMimeData
bool TrialTreeModel::dropMimeData(const QMimeData *mimeData, Qt::DropAction action, int row, int column, const QModelIndex &parent)
{
if (QStandardItemModel::dropMimeData(mimeData, action, row, column, parent))
return true;
if (mimeData->hasUrls())
{
const QList<QUrl> urls = mimeData->urls();
QStandardItem * dropInto = itemFromIndex(parent);
if (dropInto && !dropInto->data().isNull())
{
// printf("Dropping onto '%s'\n", dropInto->data().toString().toAscii().data());
QStandardItem * const tmp = new QStandardItem("Group");
QStandardItem * const p = (dropInto->parent() ? dropInto->parent() : invisibleRootItem());
p->insertRow(dropInto->row(), tmp);
tmp->setChild(0, 0, dropInto->clone());
p->removeRow(dropInto->row());
dropInto = tmp;
}
if (!dropInto)
dropInto = invisibleRootItem();
int i = 0;
for (QList<QUrl>::const_iterator it = urls.begin(); it != urls.end(); ++it, i++)
{
QFileInfo fileInfo(it->toLocalFile());
QStandardItem * const newItem = new QStandardItem(fileInfo.fileName());
newItem->setData(QDir::current().relativeFilePath(fileInfo.filePath()));
newItem->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled | Qt::ItemIsDragEnabled/* | Qt::ItemIsDropEnabled*/);
dropInto->appendRow(newItem);
}
return true;
}
return false;
}
示例3: loadOutline
static void loadOutline(miniexp_t outlineExp, int offset, QStandardItem* parent, const QHash< QString, int >& indexByName)
{
const int outlineLength = miniexp_length(outlineExp);
for(int outlineN = qMax(0, offset); outlineN < outlineLength; ++outlineN)
{
miniexp_t bookmarkExp = miniexp_nth(outlineN, outlineExp);
const int bookmarkLength = miniexp_length(bookmarkExp);
if(bookmarkLength <= 1 || !miniexp_stringp(miniexp_nth(0, bookmarkExp)) || !miniexp_stringp(miniexp_nth(1, bookmarkExp)))
{
continue;
}
const QString title = QString::fromUtf8(miniexp_to_str(miniexp_nth(0, bookmarkExp)));
QString destination = QString::fromUtf8(miniexp_to_str(miniexp_nth(1, bookmarkExp)));
if(!title.isEmpty() && !destination.isEmpty())
{
if(destination.at(0) == QLatin1Char('#'))
{
destination.remove(0,1);
bool ok = false;
int destinationPage = destination.toInt(&ok);
if(!ok)
{
if(indexByName.contains(destination))
{
destinationPage = indexByName[destination] + 1;
}
else
{
continue;
}
}
QStandardItem* item = new QStandardItem(title);
item->setFlags(Qt::ItemIsEnabled | Qt::ItemIsSelectable);
item->setData(destinationPage, Qt::UserRole + 1);
QStandardItem* pageItem = item->clone();
pageItem->setText(QString::number(destinationPage));
pageItem->setTextAlignment(Qt::AlignRight);
parent->appendRow(QList< QStandardItem* >() << item << pageItem);
if(bookmarkLength >= 3)
{
loadOutline(bookmarkExp, 2, item, indexByName);
}
}
}
}
}
示例4: addEntry
void ToolBarDialog::addEntry()
{
QStandardItem *sourceItem = m_ui->availableEntriesItemView->getItem(m_ui->availableEntriesItemView->getCurrentRow());
if (sourceItem)
{
m_ui->currentEntriesItemView->insertRow(sourceItem->clone());
}
}
示例5: readBookmark
void XbelReader::readBookmark(QStandardItem *item)
{
QStandardItem *bookmark = createChildItem(item);
bookmark->setIcon(bookmarkIcon);
bookmark->setText(QCoreApplication::translate("Help::Internal::XbelReader", "Unknown title"));
bookmark->setData(attributes().value(QLatin1String("href")).toString(),
Qt::UserRole + 10);
while (!atEnd()) {
readNext();
if (isEndElement())
break;
if (isStartElement()) {
if (name() == QLatin1String("title"))
bookmark->setText(readElementText());
else
readUnknownElement();
}
}
listModel->appendRow(bookmark->clone());
}