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


C++ QDrag类代码示例

本文整理汇总了C++中QDrag的典型用法代码示例。如果您正苦于以下问题:C++ QDrag类的具体用法?C++ QDrag怎么用?C++ QDrag使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了QDrag类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: QDrag

QDrag *DndFactory::createDrag( Incidence *incidence, QWidget *owner )
{
  QDrag *drag = new QDrag( owner );
  drag->setMimeData( createMimeData( incidence ) );

  if ( incidence->type() == "Event" ) {
    drag->setPixmap( BarIcon( "view-calendar-day" ) );
  } else if ( incidence->type() == "Todo" ) {
    drag->setPixmap( BarIcon( "view-calendar-tasks" ) );
  }

  return drag;
}
开发者ID:pvuorela,项目名称:kcalcore,代码行数:13,代码来源:dndfactory.cpp

示例2: assert

void DragHandle::mouseMoveEvent(QMouseEvent* ev) {
  assert(_panel != NULL);

  if(!_panel || !_pressed || (ev->pos() - _clickPosition).manhattanLength() < QApplication::startDragDistance())
    return;

  QDrag* drag = new QDrag(_panel);
  PanelMimeType* mimedata = new PanelMimeType();
  mimedata->setPanel(_panel);
  drag->setMimeData(mimedata);
  drag->setPixmap(_panel->view()->snapshot(QSize(100,100)));
  drag->exec(Qt::MoveAction);
}
开发者ID:mneumann,项目名称:tulip,代码行数:13,代码来源:DragHandle.cpp

示例3: currentItem

void BlockNavigationTreeWidget::performDrag()
{
	QTreeWidgetItem *item = currentItem();
	if(item)
	{
		QMimeData *mimeData = new QMimeData;
		QString text = item->text(0);
		mimeData->setText(item->text(0));
		QDrag* drag = new QDrag(this);
		drag->setMimeData(mimeData);
		m_DropAction = drag->exec( Qt::CopyAction );
	}
}
开发者ID:pholz,项目名称:UberCode,代码行数:13,代码来源:BlockNavigationTreeWidget.cpp

示例4: QDrag

void ImageWidget::mouseMoveEvent(QMouseEvent *event)
{
    if ((event->buttons() & Qt::LeftButton) &&
            (event->pos() - mDragStartPos).manhattanLength() > QApplication::startDragDistance()) {

        if (mHasImage) {
            QDrag *drag = new QDrag(this);
            drag->setMimeData(new QMimeData());
            drag->mimeData()->setImageData(mPicture.data());
            drag->start();
        }
    }
}
开发者ID:quazgar,项目名称:kdepimlibs,代码行数:13,代码来源:imagewidget.cpp

示例5: connect

//![0]
void SourceWidget::startDrag()
{
    mimeData = new MimeData;

    connect(mimeData, SIGNAL(dataRequested(QString)),
            this, SLOT(createData(QString)), Qt::DirectConnection);

    QDrag *drag = new QDrag(this);
    drag->setMimeData(mimeData);
    drag->setPixmap(QPixmap(":/images/drag.png"));

    drag->exec(Qt::CopyAction);
}
开发者ID:MarianMMX,项目名称:MarianMMX,代码行数:14,代码来源:sourcewidget.cpp

示例6: startActionDrag

void startActionDrag(QWidget *dragParent, ActionModel *model, const QModelIndexList &indexes, Qt::DropActions supportedActions)
{
    if (indexes.empty())
        return;

    QDrag *drag = new QDrag(dragParent);
    QMimeData *data = model->mimeData(indexes);
    drag->setMimeData(data);
    if (ActionRepositoryMimeData *actionMimeData = qobject_cast<ActionRepositoryMimeData *>(data))
        drag->setPixmap(ActionRepositoryMimeData::actionDragPixmap(actionMimeData->actionList().front()));

    drag->start(supportedActions);
}
开发者ID:Fale,项目名称:qtmoko,代码行数:13,代码来源:actionrepository.cpp

示例7: QDrag

void LayerControlWidgetBase::mouseMoveEvent(QMouseEvent *event)
{
  if (!(event->buttons() & Qt::LeftButton))
    return;

  if ((event->pos() - _dragStartPosition).manhattanLength() < QApplication::startDragDistance())
    return;

  QDrag *drag = new QDrag(this);
  drag->setMimeData(new LayerWidgetMimeData(this));

  Qt::DropAction dropAction = drag->exec(Qt::MoveAction);
}
开发者ID:caishanli,项目名称:osgearth,代码行数:13,代码来源:LayerManagerWidget.cpp

示例8: QDrag

void NowPlayingListWidget::mousePressEvent(QMouseEvent *event)
{
    //after checking if we are in presence of a drag operation, we can then encapsulate
    //the data to be sent and let start the drag operation
    if (event->button() == Qt::LeftButton && itemAt(event->pos())) {
        QDrag *drag = new QDrag(this);
        QMimeData *mimeData = new QMimeData();

        mimeData->setText(itemAt(event->pos())->text()); //who receives expects plain text data
        drag->setMimeData(mimeData);
        drag->exec();
    }
}
开发者ID:KDE,项目名称:ktp-kded-module,代码行数:13,代码来源:nowplaying-listwidget.cpp

示例9: QDrag

void ImageWIdget::makeDrag()
{
    QDrag *dr = new QDrag(this);
    // The data to be transferred by the drag and drop operation is contained in a QMimeData object
    QMimeData *data = new QMimeData;
    data->setText(myS.img.image_file);

    // Assign ownership of the QMimeData object to the QDrag object.
    dr->setMimeData(data);
    // Start the drag and drop operation
    dr->start();

}
开发者ID:mtparet,项目名称:PecsQt,代码行数:13,代码来源:imagewidget.cpp

示例10: assert

	void BlockButton::mouseMoveEvent( QMouseEvent *event )
	{
		#ifndef ANDROID
		assert(block);
		
		QDrag *drag = new QDrag(this);
		drag->setMimeData(block->mimeData());
		drag->setPixmap(QPixmap::fromImage(block->translucidImage(vpl->getViewScale())));
		const qreal thisScale = width() / 256.;
		drag->setHotSpot(event->pos()*vpl->getViewScale() / thisScale);
		drag->exec(Qt::CopyAction);
		#endif // ANDROID
	}
开发者ID:retornaz,项目名称:aseba,代码行数:13,代码来源:Buttons.cpp

示例11: tabAt

void TabBar::mouseMoveEvent(QMouseEvent *event)
{
    if(!(event->buttons() & Qt::LeftButton) || !tabsClosable())
        return PlusTabBar::mouseMoveEvent(event);

    if((event->pos() - m_startDragPos).manhattanLength() < QApplication::startDragDistance())
        return PlusTabBar::mouseMoveEvent(event);

    int idx = tabAt(event->pos());
    if(idx == -1)
        return PlusTabBar::mouseMoveEvent(event);

    event->accept();

    QDrag *drag = new QDrag(this);

    tabView()->createSplitOverlay(m_id, drag);

    QStyleOptionTabV3 tab;
    initStyleOption(&tab, idx);

    QWidget *tabWidget = ((QTabWidget*)parent())->widget(idx);
    QPixmap wMap(tabWidget->size());
    tabWidget->render(&wMap);

    if(wMap.width() > 400 || wMap.height() > 400)
        wMap = wMap.scaled(400, 400, Qt::KeepAspectRatio,
                           sConfig.get(CFG_BOOL_SMOOTH_SCALING) ? Qt::SmoothTransformation : Qt::FastTransformation);

    QSize size = tabRect(idx).size();
    size.rwidth() = std::max(wMap.width(), size.width());
    size.rheight() += wMap.height();

    QPixmap map(size);
    map.fill(Qt::transparent);

    QStylePainter p(&map, this);
    p.initFrom(this);
    p.drawItemPixmap(QRect(0, tab.rect.height()-5, wMap.width(), wMap.height()), 0, wMap);

    tab.rect.moveTopLeft(QPoint(0, 0));
    p.drawControl(QStyle::CE_TabBarTab, tab);
    p.end();

    QMimeData *mime = new QMimeData();
    mime->setData("data/tabinfo", QString("%1 %2 %3").arg(m_id).arg(idx).arg(tabView()->getWindowId()).toLatin1());

    drag->setPixmap(map);
    drag->setMimeData(mime);
    drag->exec();
}
开发者ID:dimitarm1,项目名称:Lorris,代码行数:51,代码来源:tabwidget.cpp

示例12: qDebug

void CRenderClientsListView::performDrag()
{
	qDebug() << QString("performDrag");

    CRenderClientsListModel* lmodel = reinterpret_cast<CRenderClientsListModel*>(model());

    QModelIndexList indexList = selectedIndexes();
    CModelDiff md(m_role);

    for(int i = 0; i < indexList.size(); i++)
    {
    	comb_hash_t combhash;
		CItemBase* item = lmodel->itemFromIndex(indexList.at(i));
		switch(item->type()) {
		case CItemType::E_STREAM_CLIENT:
		{
    		CStreamClientItem* scItem = reinterpret_cast<CStreamClientItem*>(item);
			combhash.type = scItem->type();
			if(m_role == E_OWN_RENDER_CLIENT) {
			    int filteredline = lmodel->own2availIndex(indexList.at(i).row());
	            combhash.line = filteredline;
			}
			else {
                combhash.line = indexList.at(i).row();
			}

			md.appendToSelectedItems(combhash);
		}
		default:
			break;
		}
    }

    if (md.getNumSelected() > 0)
    {
    	QMimeData *mimeData = new QMimeData;
        //mimeData->setText(item->asString());
        mimeData->setData(dndMimeType, md.toQByteArray());

        m_dragActive = true;
        QDrag *drag = new QDrag(this);
        drag->setMimeData(mimeData);
        // drag->setPixmap(QPixmap(":/images/person.png"));

        Qt::DropAction action = drag->exec(Qt::MoveAction);

        m_dragActive = false;
        qDebug() << QString("DropAction: %1").arg(action);

    }
}
开发者ID:MarcelTh,项目名称:muroa,代码行数:51,代码来源:CRenderClientsListView.cpp

示例13: QDrag

void pa_db::free_elements_widget::mouseMoveEvent( QMouseEvent *event )
{
	if ( event->buttons( ) & Qt::LeftButton )
	{
		if ( currentItem( ) )
		{
			QDrag *drag = new QDrag( this );
			QMimeData *mimeData = new QMimeData;
			mimeData->setData( pa_db::text::free_element_mime_data( ), currentItem( )->data( Qt::UserRole ).toByteArray( ) );
			drag->setMimeData( mimeData );
			drag->start( Qt::MoveAction );
		}
	}
}
开发者ID:nextgis,项目名称:padb,代码行数:14,代码来源:free_elements_widget.cpp

示例14: currentItem

void ProjectListWidget::startDrag()
{
    QListWidgetItem *item = currentItem();
    if (item) {
        QMimeData *mimeData = new QMimeData;
        mimeData->setText(item->text());

        QDrag *drag = new QDrag(this);
        drag->setMimeData(mimeData);
        drag->setPixmap(QPixmap(":/images/person.png"));
        if (drag->start(Qt::MoveAction) == Qt::MoveAction)
            delete item;
    }
}
开发者ID:evade55,项目名称:station-meteo-test,代码行数:14,代码来源:projectlistwidget.cpp

示例15: QDrag

void pa_db::species_widget::mouseMoveEvent( QMouseEvent *event )
{
	if ( event->buttons() & Qt::LeftButton )
	{
		if ( currentItem() )
		{
			QDrag *drag = new QDrag( this );
			QMimeData *mimeData = new QMimeData;
			mimeData->setData( "application/x-qt-windows-mime;value=\"species_mime_data\"", currentItem()->data( Qt::UserRole ).toByteArray() );
			drag->setMimeData( mimeData );
			drag->start( Qt::CopyAction );
		}
	}
}
开发者ID:nextgis,项目名称:padb,代码行数:14,代码来源:species_widget.cpp


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