当前位置: 首页>>代码示例>>C++>>正文


C++ QMimeData::setData方法代码示例

本文整理汇总了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;
}
开发者ID:3liz,项目名称:Quantum-GIS,代码行数:18,代码来源:qgsgraduatedsymbolrendererwidget.cpp

示例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;
}
开发者ID:wgsyd,项目名称:wgtf,代码行数:19,代码来源:wg_merge_proxy.cpp

示例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();

};
开发者ID:jeez,项目名称:iqr,代码行数:19,代码来源:ClsQNeuronStateVariableDisplay.cpp

示例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;
}
开发者ID:chocoball,项目名称:AnimationCreator,代码行数:19,代码来源:objectmodel.cpp

示例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);
}
开发者ID:MazharLakhani,项目名称:ImagePlay,代码行数:19,代码来源:IPProcessList.cpp

示例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);
}
开发者ID:SchleunigerAG,项目名称:WinEC7_Qt5.3.1_Fixes,代码行数:19,代码来源:tst_qmimedata.cpp

示例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);
            }
      }
开发者ID:dc7kr,项目名称:MuseScore,代码行数:43,代码来源:palette.cpp

示例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);

}
开发者ID:SpelaOman,项目名称:BubiRacun,代码行数:43,代码来源:wid_stranke.cpp

示例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 );
}
开发者ID:zaps166,项目名称:DSPBlocks,代码行数:19,代码来源:BlocksTree.cpp

示例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;
  }
}
开发者ID:DanNixon,项目名称:mantid,代码行数:19,代码来源:DockedWindow.cpp

示例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;
}
开发者ID:xinyazhang,项目名称:oldstuff-moonstone,代码行数:19,代码来源:KBModel.cpp

示例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;
}
开发者ID:freexploit,项目名称:print-manager,代码行数:19,代码来源:PrintQueueModel.cpp

示例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;
}
开发者ID:fluxer,项目名称:kde-workspace,代码行数:19,代码来源:SensorBrowser.cpp

示例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;
}
开发者ID:RobinWuDev,项目名称:Qt,代码行数:19,代码来源:bookmarks.cpp

示例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);
  }
}
开发者ID:BlueQuartzSoftware,项目名称:SIMPLView,代码行数:22,代码来源:FilterListWidget.cpp


注:本文中的QMimeData::setData方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。