本文整理汇总了C++中QMimeData::setData方法的典型用法代码示例。如果您正苦于以下问题:C++ QMimeData::setData方法的具体用法?C++ QMimeData::setData怎么用?C++ QMimeData::setData使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QMimeData
的用法示例。
在下文中一共展示了QMimeData::setData方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: stream
QMimeData *QgsGraduatedSymbolRendererModel::mimeData( const QModelIndexList &indexes ) const
{
QMimeData *mimeData = new QMimeData();
QByteArray encodedData;
QDataStream stream( &encodedData, QIODevice::WriteOnly );
// Create list of rows
Q_FOREACH ( const QModelIndex &index, indexes )
{
if ( !index.isValid() || index.column() != 0 )
continue;
stream << index.row();
}
mimeData->setData( mMimeFormat, encodedData );
return mimeData;
}
示例2: mimeData
QMimeData* WGMergeProxy::mimeData(const QModelIndexList &indexes) const
{
QMimeData* data = new QMimeData();
for(const auto& index : indexes)
{
auto pair = mappingFromIndex(index);
if(pair.first)
{
QMimeData* mimeData = pair.first->model_->mimeData({index});
for (auto& format : mimeData->formats())
{
data->setData(format, mimeData->data(format));
}
}
}
return data;
}
示例3: startDragging
void ClsQNeuronStateVariableDisplay::startDragging(bool bCopy) {
#ifdef DEBUG_CLSQSTATEVARIABLEDISPLAY
cout << "ClsQNeuronStateVariableDisplay::startDragging()" << endl;
#endif
QDrag *drag = new QDrag(this);
string strParamList=getSelectedStatesAsString();
string str = "";
str = ClsDragDropDeEncoder::encode(ClsFESystemManager::ITEM_GROUP, clsFEGroup->getGroupID(), strParamList, strSelectedIndices);
QMimeData *mimeData = new QMimeData;
mimeData->setData("text/iqr-plot", str.c_str());
drag->setMimeData(mimeData);
Qt::DropAction dropAction = drag->exec();
};
示例4: stream
QMimeData *ObjectModel::mimeData(const QModelIndexList &indexes) const
{
QMimeData *mimeData = new QMimeData();
QByteArray encodeData;
qDebug() << "mimeData";
QDataStream stream(&encodeData, QIODevice::WriteOnly);
foreach (const QModelIndex &index, indexes)
{
if (index.isValid())
{
stream << reinterpret_cast<quint64>(index.internalPointer());
qDebug() << reinterpret_cast<quint64>(index.internalPointer());
}
}
mimeData->setData("AnimationCreator/object.item.list", encodeData);
return mimeData;
}
示例5: startDrag
void IPProcessList::startDrag(Qt::DropActions)
{
QListWidgetItem* item = currentItem();
QMimeData* mimeData = new QMimeData;
QByteArray processID;
processID.append(item->toolTip());
mimeData->setData("application/x-imageplay", processID);
QPixmap dragPixmap = item->icon().pixmap(32,32);
QDrag *drag = new QDrag(this);
drag->setMimeData(mimeData);
drag->setPixmap(dragPixmap);
drag->setHotSpot(QPoint(16,16));
drag->exec(Qt::MoveAction);
//QListWidget::startDrag(supportedActions);
}
示例6: hasImage
void tst_QMimeData::hasImage() const
{
QMimeData mimeData;
// initial state
QVERIFY(mimeData.hasImage() == false);
// add text, verify false
mimeData.setData("text/plain", "pirates");
QVERIFY(mimeData.hasImage() == false);
// add image
mimeData.setImageData(QImage());
QVERIFY(mimeData.hasImage());
// clear, verify
mimeData.clear();
QVERIFY(mimeData.hasImage() == false);
}
示例7: mouseMoveEvent
void Palette::mouseMoveEvent(QMouseEvent* ev)
{
if ((currentIdx != -1) && (dragIdx == currentIdx) && (ev->buttons() & Qt::LeftButton)
&& (ev->pos() - dragStartPosition).manhattanLength() > QApplication::startDragDistance()) {
PaletteCell* cell = cells[currentIdx];
if (cell && cell->element) {
QDrag* drag = new QDrag(this);
QMimeData* mimeData = new QMimeData;
Element* el = cell->element;
qreal mag = PALETTE_SPATIUM * extraMag / gscore->spatium();
QPointF spos = QPointF(dragStartPosition) / mag;
spos -= QPointF(cells[currentIdx]->x, cells[currentIdx]->y);
// DEBUG:
spos.setX(0.0);
mimeData->setData(mimeSymbolFormat, el->mimeData(spos));
drag->setMimeData(mimeData);
dragSrcIdx = currentIdx;
emit startDragElement(el);
if (_readOnly) {
drag->start(Qt::CopyAction);
}
else {
/*Qt::DropAction action = */
drag->start(Qt::DropActions(Qt::CopyAction | Qt::MoveAction));
}
}
}
else {
QRect r;
if (currentIdx != -1)
r = idxRect(currentIdx);
currentIdx = idx(ev->pos());
if (currentIdx != -1) {
if (cells[currentIdx] == 0)
currentIdx = -1;
else
r |= idxRect(currentIdx);
}
update(r);
}
}
示例8: on_btn_kopiraj_clicked
void wid_stranke::on_btn_kopiraj_clicked() {
QClipboard *odlozisce = QApplication::clipboard();
QModelIndexList selectedList = ui->tbl_stranke->selectionModel()->selectedRows();
QString html_besedilo = "<table>";
html_besedilo += "<tr>";
html_besedilo += "<th>ID</th>";
html_besedilo += "<th>Ime/Naziv</th>";
html_besedilo += "<th>Priimek/Polni naziv</th>";
html_besedilo += "<th>Telefon</th>";
html_besedilo += "<th>GSM</th>";
html_besedilo += "<th>Elektronski naslov</th>";
html_besedilo += "<th>Izobrazevalna ustanova</th>";
html_besedilo += "<th>Tip stranke</th>";
html_besedilo += "</tr>";
for( int i = 0; i < selectedList.count(); i++) {
html_besedilo += "<tr>";
for ( int a = 0; a < 8; a++ ) {
html_besedilo += "<td>";
html_besedilo += ui->tbl_stranke->item(selectedList.at(i).row(), a)->text();
html_besedilo += "</td>";
}
html_besedilo += "</tr>";
}
html_besedilo += "</table>";
QTextEdit *textedit = new QTextEdit;
textedit->setHtml(html_besedilo);
html_besedilo = textedit->toHtml();
odlozisce->clear();
QMimeData *mimeData = new QMimeData();
mimeData->setData("text/html", html_besedilo.toUtf8());
odlozisce->setMimeData(mimeData, QClipboard::Clipboard);
}
示例9: mouseMoveEvent
void BlocksTree::mouseMoveEvent( QMouseEvent *event )
{
if ( event->buttons() & Qt::LeftButton )
{
QTreeWidgetItem *tWI = itemAt( event->pos() );
if ( tWI && tWI->parent() && tWI->isSelected() )
{
QMimeData *mimeData = new QMimeData;
Block *block = ( Block * )tWI->data( 0, Qt::UserRole ).value< quintptr >();
mimeData->setData( "Block", QByteArray( ( const char * )&block, sizeof block ) );
QDrag *drag = new QDrag( this );
drag->setPixmap( tWI->data( 0, Qt::DecorationRole ).value< QPixmap >() );
drag->setMimeData( mimeData );
drag->exec();
}
}
QTreeWidget::mouseMoveEvent( event );
}
示例10: dragMouseMove
void DockedWindow::dragMouseMove(QPoint pos) {
if (m_dragMouseDown) {
if ((pos - m_dragStartPos).manhattanLength() <
QApplication::startDragDistance()) {
return;
}
QDrag *drag = new QDrag(d_app);
QMimeData *mimeData = new QMimeData;
MdiSubWindow *ptr = mdiSubWindow();
auto d = QByteArray::fromRawData((const char *)ptr, 1);
mimeData->setData("TiledWindow", d);
drag->setMimeData(mimeData);
Qt::DropAction dropAction = drag->exec(Qt::CopyAction | Qt::MoveAction);
(void)dropAction;
}
}
示例11: mimeData
QMimeData* KBModel::mimeData(const QModelIndexList &indexes) const
{
QMimeData *mimeData = new QMimeData();
QByteArray encodedData;
QDataStream stream(&encodedData, QIODevice::WriteOnly);
foreach (const QModelIndex &index, indexes)
{
if (index.isValid())
{
const KBViewItem* item = static_cast<const KBViewItem*>(index.internalPointer());
item->append_binary_layerout(stream);
}
}
mimeData->setData("application/lain.local_binary_objects", encodedData);
return mimeData;
}
示例12: mimeData
QMimeData* PrintQueueModel::mimeData(const QModelIndexList &indexes) const
{
QMimeData *mimeData = new QMimeData();
QByteArray encodedData;
QDataStream stream(&encodedData, QIODevice::WriteOnly);
foreach (const QModelIndex &index, indexes) {
if (index.isValid() && index.column() == 0) {
// serialize the jobId and fromDestName
stream << data(index, JobId).toInt()
<< data(index, DestName).toString()
<< item(index.row(), ColName)->text();
}
}
mimeData->setData("application/x-cupsjobs", encodedData);
return mimeData;
}
示例13: QMimeData
QMimeData * SensorBrowserModel::mimeData ( const QModelIndexList & indexes ) const { //virtual
QMimeData *mimeData = new QMimeData();
if(indexes.size() != 1) return mimeData;
SensorInfo *sensor = getSensorInfo(indexes[0]);
if(!sensor) return mimeData;
// Create text drag object as
// "<hostname> <sensorname> <sensortype> <sensordescription>".
// Only the description may contain blanks.
Q_ASSERT(sensor);
Q_ASSERT(sensor->hostInfo());
QString mDragText = sensor->hostInfo()->hostName() + ' ' +
sensor->name() + ' ' +
sensor->type()+ ' ' +
sensor->description();
mimeData->setData( "application/x-ksysguard", mDragText.toUtf8() );
return mimeData;
}
示例14: stream
QMimeData *BookmarksModel::mimeData(const QModelIndexList &indexes) const
{
QMimeData *mimeData = new QMimeData();
QByteArray data;
QDataStream stream(&data, QIODevice::WriteOnly);
foreach (QModelIndex index, indexes) {
if (index.column() != 0 || !index.isValid())
continue;
QByteArray encodedData;
QBuffer buffer(&encodedData);
buffer.open(QBuffer::ReadWrite);
XbelWriter writer;
const BookmarkNode *parentNode = node(index);
writer.write(&buffer, parentNode);
stream << encodedData;
}
mimeData->setData(MIMETYPE, data);
return mimeData;
}
示例15: performDrag
// -----------------------------------------------------------------------------
//
// -----------------------------------------------------------------------------
void FilterListWidget::performDrag()
{
QListWidgetItem* item = currentItem();
if(item)
{
QJsonObject obj;
obj[item->text()] = item->data(Qt::UserRole).toString();
QJsonDocument doc(obj);
QByteArray jsonArray = doc.toJson();
QMimeData* mimeData = new QMimeData;
mimeData->setData(SIMPL::DragAndDrop::FilterItem, jsonArray);
QDrag* drag = new QDrag(this);
drag->setMimeData(mimeData);
drag->exec(Qt::CopyAction);
}
}