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


C++ QDropEvent类代码示例

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


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

示例1: rect

bool QLineEdit::event( QEvent * e )
{
#if 0 // it works, but we'll wait with enabling it.
    if ( !e )
	return QWidget::event( e );

    if ( e->type() == Event_DragEnter ) {
	if ( ((QDragEnterEvent *) e)->provides( "text/plain" ) ) {
	    ((QDragEnterEvent *) e)->accept( rect() );
	    return TRUE;
	}
    } else if ( e->type() == Event_DragLeave ) {
	return TRUE;
    } else if ( e->type() == Event_Drop ) {
	QDropEvent * de = (QDropEvent *) e;
	QString str;
	if ( QTextDrag::decode( de, str ) ) {
	    if ( !hasMarkedText() ) {
		int margin = frame() ? 2 : 0;
		setCursorPosition( xPosToCursorPos( &tbuf[(int)offset],
						    fontMetrics(),
						    de->pos().x() - margin,
						    width() - 2*margin ) );
	    }
	    insert( str );
	    de->accept();
	} else {
	    de->ignore();
	}
	return TRUE;
    }
#endif
    return QWidget::event( e );
}
开发者ID:kthxbyte,项目名称:Qt1.45-Linaro,代码行数:34,代码来源:qlineedit.cpp

示例2: switch

bool DockedMdiArea::event(QEvent *event)
{
    // Listen for desktop file manager drop and emit a signal once a file is
    // dropped.
    switch (event->type()) {
    case QEvent::DragEnter: {
        QDragEnterEvent *e = static_cast<QDragEnterEvent*>(event);
        if (!uiFiles(e->mimeData()).empty()) {
            e->acceptProposedAction();
            return true;
        }
    }
        break;
    case QEvent::Drop: {
        QDropEvent *e = static_cast<QDropEvent*>(event);
        const QStringList files = uiFiles(e->mimeData());
        const QStringList::const_iterator cend = files.constEnd();
        for (QStringList::const_iterator it = files.constBegin(); it != cend; ++it) {
            emit fileDropped(*it);
        }
        e->acceptProposedAction();
        return true;
    }
        break;
    default:
        break;
    }
    return QMdiArea::event(event);
}
开发者ID:stephaneAG,项目名称:PengPod700,代码行数:29,代码来源:mainwindow.cpp

示例3: if

bool FormFile::eventFilter(QObject *watched, QEvent *event)
{
    if(watched == ui->lvServer)
    {
        if(event->type() == QEvent::DragEnter)
        {
            QDragEnterEvent* dee = dynamic_cast<QDragEnterEvent*>(event);
            dee->acceptProposedAction();
            return true;
        }
        else if(event->type() == QEvent::Drop)
        {
            QDropEvent* de = dynamic_cast<QDropEvent*>(event);
            QList<QUrl>urls = de->mimeData()->urls();
            if(urls.isEmpty())
            {
                return true;
            }
            QString path = urls.first().toLocalFile();
            //上传文件
            updateFile(path, path.split("/").last());
            return true;
        }
    }

    return QWidget::eventFilter(watched, event);
}
开发者ID:eilin1208,项目名称:QT_Test,代码行数:27,代码来源:formfile.cpp

示例4: eventFilter

// Eventfilter: Only needed under Windows.
// Without this, files dropped in the line edit have URL-encoding.
// This eventfilter decodes the filenames as needed by KDiff3.
bool OpenDialog::eventFilter(QObject* o, QEvent* e)
{
   if ( e->type()==QEvent::DragEnter )
   {
      QDragEnterEvent* d = static_cast<QDragEnterEvent*>(e);
      d->setAccepted( d->mimeData()->hasUrls() );
      return true;
   }
   if (e->type()==QEvent::Drop)
   {
      QDropEvent* d = static_cast<QDropEvent*>(e);

      if ( !d->mimeData()->hasUrls() )
         return false;

      QList<QUrl> lst = d->mimeData()->urls();

      if ( lst.count() > 0 )
      {
         static_cast<QLineEdit*>(o)->setText( QDir::toNativeSeparators( lst[0].toLocalFile() ) );
         static_cast<QLineEdit*>(o)->setFocus();
      }
       
      return true;
   }
   return false;
}
开发者ID:nigels-com,项目名称:nvidia-kdiff3,代码行数:30,代码来源:smalldialogs.cpp

示例5: msgEventAccepted

static QString msgEventAccepted(const QDropEvent &e)
{
    QString message;
    QTextStream str(&message);
    str << "Event at " << e.pos().x() << ',' << e.pos().y() << ' ' << (e.isAccepted() ? "accepted" : "ignored");
    return message;
}
开发者ID:,项目名称:,代码行数:7,代码来源:

示例6: if

 bool DropFilter::eventFilter(QObject *obj, QEvent *event)
 {
     if( event->type() == QEvent::DragEnter)
     {
         QDragEnterEvent *dragEvent=dynamic_cast< QDragEnterEvent* >(event);
         if (dragEvent->mimeData()->hasFormat("text/plain"))
         {
             QString data = dragEvent->mimeData()->text();
             dragEvent->acceptProposedAction();
         }
     }
     else if (event->type() == QEvent::Drop )
     {
         QDropEvent* dropEvent = dynamic_cast< QDropEvent* >(event);
         QString data = dropEvent->mimeData()->text();
         ::fwServices::ObjectMsg::sptr message = ::fwServices::ObjectMsg::New();
         message->addEvent("DROPPED_UUID", ::fwData::String::New(data.toStdString()));
         ::fwServices::IService::sptr service = m_service.lock();
         ::fwServices::IEditionService::notify( service, service->getObject< ::fwData::Object >(), message );
     } else {
         // standard event processing
         return QObject::eventFilter(obj, event);
     }
     return true;
 }
开发者ID:corentindesfarges,项目名称:fw4spl,代码行数:25,代码来源:VtkRenderWindowInteractorManager.cpp

示例7: QWidget


//.........这里部分代码省略.........
        emit layerSelected(layer->layerId, layer->name);
}

    //****************************************************************************/
    void QtLayerWidget::mouseClickHandler(QMouseEvent* event)
    {
        switch ((int) event->button())
        {
            case Qt::LeftButton:
            {
                // TODO
            }
            break;

            case Qt::RightButton:
            {
                QPoint pos;
                pos.setX(event->screenPos().x());
                pos.setY(event->screenPos().y());
                mContextMenu->popup(pos);
            }
            break;
        }
    }

    //****************************************************************************/
    void QtLayerWidget::mouseDblClickHandler(QMouseEvent* event)
    {
        switch ((int) event->button())
        {
            case Qt::LeftButton:
            {
                if (mTable->currentColumn() == TOOL_LAYER_COLUMN_NAME)
                {
                    QTableWidgetItem* item = mTable->currentItem();
                    if (item->column() == TOOL_LAYER_COLUMN_NAME)
                    {
                        // Its the name; edit it
                        mTable->editItem(item);
                    }
                }
            }
            break;
        }
    }

    //****************************************************************************/
    void QtLayerWidget::dropHandler(QObject* object, QEvent* event)
    {
        event->accept();

        if (!mListenToDropEvents)
            return;

        if (!mListenToSceneViewWidget)
            return;

        // Determine whether the data was from an abstractitem modellist
        QDropEvent* dropEvent = static_cast<QDropEvent*>(event);
        const QMimeData* mimeData = dropEvent->mimeData();
        QString mimeType("application/x-qabstractitemmodeldatalist");
        if (!mimeData->hasFormat(mimeType))
            return;

        // Do not use the mimeData to retrieve the sceneview tree item, because a standard model is used,
        // which does not return the data that is needed.
        // Use the data of the selected item in the sceneview (mListenToSceneId) as an alternative.
        if (mTable->rowCount() > 0 && mSceneViewWidget)
        {
            // Get the dropped item (this is the currently selected item of mListenToSceneId in widget mListenToSceneViewWidget)
            QTreeWidgetItem* item = mListenToSceneViewWidget->getCurrentItem(mListenToSceneId);
            if (item)
            {
                // The layerId of the selected layer = the sceneId of the visible sceneview tree in mSceneViewWidget
                // The currently selected group in the mListenToSceneViewWidget = the destination group of mSceneViewWidget
                int layerId = getCurrentLayerId();
                int groupId = mListenToSceneViewWidget->getCurrentGroupId(item);

                // 1. Add the group; this is ignored if the group is already available
                QtAssetGroup assetGroupInfo = mListenToSceneViewWidget->getGroupInfo(groupId);
                mSceneViewWidget->addGroupToSceneView(layerId,
                                                      assetGroupInfo.groupIcon,
                                                      groupId,
                                                      assetGroupInfo.groupName,
                                                      false);

                // 2. Determine the item type and add either the asset or all assets in a group
                if (mListenToSceneViewWidget->itemIsGroup(item))
                {
                    // The dropped item is a GROUP
                    // Add all the items of the source group to the destination group
                    QVector<QTreeWidgetItem*> assetVec = mListenToSceneViewWidget->getAssetItemsOfGroup(mListenToSceneId, groupId);
                    foreach (QTreeWidgetItem* assetItem, assetVec)
                    {
                        mSceneViewWidget->addAssetToSceneView(layerId,
                                                              groupId,
                                                              mSceneViewWidget->getAssetIdOfAssetItem(assetItem),
                                                              assetItem->text(0));
                    }
                }
开发者ID:galek,项目名称:Magus,代码行数:101,代码来源:tool_layerwidget.cpp

示例8: if

bool CloudView::eventFilter(QObject *obj, QEvent *event)
{
    if (obj == mHeader) {
        static QPoint oldPos;
        if (event->type() == QEvent::MouseButtonPress) {
            QMouseEvent *ev = (QMouseEvent *)event;
            oldPos = ev->globalPos();

            return true;

        } else if (event->type() == QEvent::MouseMove) {
            QMouseEvent *ev = (QMouseEvent *)event;
            const QPoint delta = ev->globalPos() - oldPos;

            MainWindow *win = seafApplet->mainWindow();
            win->move(win->x() + delta.x(), win->y() + delta.y());

            oldPos = ev->globalPos();
            return true;
        }

    } else if (obj == mDropArea) {
        if (event->type() == QEvent::DragEnter) {
            QDragEnterEvent *ev = (QDragEnterEvent *)event;
            if (ev->mimeData()->hasUrls() && ev->mimeData()->urls().size() == 1) {
                const QUrl url = ev->mimeData()->urls().at(0);
                if (url.scheme() == "file") {
                    QString path = url.toLocalFile();
#if defined(Q_OS_MAC) && (QT_VERSION <= QT_VERSION_CHECK(5, 4, 0))
                    path = utils::mac::fix_file_id_url(path);
#endif
                    if (QFileInfo(path).isDir()) {
                        ev->acceptProposedAction();
                    }
                }
            }
            return true;
        } else if (event->type() == QEvent::Drop) {
            QDropEvent *ev = (QDropEvent *)event;
            const QUrl url = ev->mimeData()->urls().at(0);
            QString path = url.toLocalFile();
#if defined(Q_OS_MAC) && (QT_VERSION <= QT_VERSION_CHECK(5, 4, 0))
            path = utils::mac::fix_file_id_url(path);
#endif
            ev->setDropAction(Qt::CopyAction);
            ev->accept();
            showCreateRepoDialog(path);
            return true;
        }
    }

    return QWidget::eventFilter(obj, event);
}
开发者ID:shravanAngadi,项目名称:seafile-client,代码行数:53,代码来源:cloud-view.cpp

示例9: eventFilter

bool RegisterP12::eventFilter( QObject *o, QEvent *e )
{
	if( o == d->p12Cert && e->type() == QEvent::Drop )
	{
		QDropEvent *drop = static_cast<QDropEvent*>(e);
		if( drop->mimeData()->hasUrls() )
		{
			d->p12Cert->setText( drop->mimeData()->urls().value( 0 ).toLocalFile() );
			return true;
		}
	}
	return QWidget::eventFilter( o, e );
}
开发者ID:Krabi,项目名称:idkaart_public,代码行数:13,代码来源:RegisterP12.cpp

示例10: eventFilter

bool SettingsDialog::eventFilter( QObject *o, QEvent *e )
{
	if( o == d->p12Cert && e->type() == QEvent::Drop )
	{
		QDropEvent *d = static_cast<QDropEvent*>(e);
		if( d->mimeData()->hasUrls() )
		{
			setP12Cert( d->mimeData()->urls().value( 0 ).toLocalFile() );
			return true;
		}
	}
	return QWidget::eventFilter( o, e );
}
开发者ID:Krabi,项目名称:idkaart_public,代码行数:13,代码来源:SettingsDialog.cpp

示例11: switch

bool ContextHelp::eventFilter( QObject * watched, QEvent * e )
{
// 	kDebug() << k_funcinfo << "watched="<<watched<<endl;
	
	if ( (watched != m_pEditor) && (watched != m_pEditor->editorViewport()) )
		return false;
	
	switch ( e->type() )
	{
		case QEvent::DragEnter:
		{
			QDragEnterEvent * dragEnter = static_cast<QDragEnterEvent*>(e);
			
			if ( !QString( dragEnter->format() ).startsWith("ktechlab/") )
				break;
			
			dragEnter->acceptAction();
			return true;
		}
			
		case QEvent::Drop:
		{
			QDropEvent * dropEvent = static_cast<QDropEvent*>(e);
			
			if ( !QString( dropEvent->format() ).startsWith("ktechlab/") )
				break;
			
			dropEvent->accept();
			
			QString type;
			QDataStream stream( dropEvent->encodedData( dropEvent->format() ) /*, IO_ReadOnly */ );
			stream >> type;
			
			LibraryItem * li = itemLibrary()->libraryItem( type );
			if ( !li )
				return true;
			
			m_pEditor->insertURL( "ktechlab-help:///" + type, li->name() );
			return true;
		}
			
		default:
			break;
	}
	
	return false;
}
开发者ID:ktechlab,项目名称:ktechlab-0.3,代码行数:47,代码来源:contexthelp.cpp

示例12: painter

bool AlgorithmRunner::eventFilter(QObject *obj, QEvent *ev) {
  bool draggableObject = obj == _ui->favoritesBox->widget() ||
                         _favorites.contains(dynamic_cast<AlgorithmRunnerItem *>(obj));

  if (ev->type() == QEvent::Paint) {
    if (obj == _ui->favoritesBox->widget() && _favorites.empty()) {
      QPainter painter(_ui->favoritesBox->widget());
      QPixmap px((_ui->favoritesBox->_droppingFavorite
                      ? ":/tulip/graphperspective/icons/32/favorite.png"
                      : ":/tulip/graphperspective/icons/32/favorite-empty.png"));
      painter.drawPixmap(_ui->favoritesBox->widget()->width() - px.width() - 8, 8, px);
      QFont f;
      f.setItalic(true);
      painter.setFont(f);
      painter.setBrush(QColor(107, 107, 107));
      painter.setPen(QColor(107, 107, 107));
      painter.drawText(0, 8 + (px.height() - 12) / 2, _ui->favoritesBox->widget()->width(), 65535,
                       /*Qt::AlignHCenter | Qt::AlignTop |*/ Qt::TextWordWrap,
                       "Put your favorite algorithms here");
    }
  } else if ((ev->type() == QEvent::DragEnter || ev->type() == QEvent::DragMove) &&
             draggableObject) {
    QDropEvent *dropEv = static_cast<QDropEvent *>(ev);

    if (dynamic_cast<const AlgorithmMimeType *>(dropEv->mimeData()) != nullptr) {
      _ui->favoritesBox->_droppingFavorite = true;
      ev->accept();
      _ui->favoritesBox->repaint();
    }

    return true;
  } else if (ev->type() == QEvent::DragLeave && draggableObject) {
    _ui->favoritesBox->_droppingFavorite = false;
    _ui->favoritesBox->repaint();
  } else if (ev->type() == QEvent::Drop && draggableObject) {
    QDropEvent *dropEv = static_cast<QDropEvent *>(ev);
    const AlgorithmMimeType *mime = dynamic_cast<const AlgorithmMimeType *>(dropEv->mimeData());

    if (mime != nullptr)
      addFavorite(mime->algorithm(), mime->params());

    _ui->favoritesBox->_droppingFavorite = false;
    _ui->favoritesBox->repaint();
  }

  return false;
}
开发者ID:tulip5,项目名称:tulip,代码行数:47,代码来源:AlgorithmRunner.cpp

示例13: if

/** Redefined to forward events to children. */
bool TabPlaylist::eventFilter(QObject *obj, QEvent *event)
{
	if (event->type() == QEvent::DragEnter) {
		event->accept();
		return true;
	} else if (event->type() == QEvent::Drop) {
		QDropEvent *de = static_cast<QDropEvent*>(event);
		if (de->source() == NULL) {
			// Drag & Drop comes from another application but has landed in the playlist area
			de->ignore();
			QDropEvent *d = new QDropEvent(de->pos(), de->possibleActions(), de->mimeData(), de->mouseButtons(), de->keyboardModifiers());
			_mainWindow->dispatchDrop(d);
			return true;
		} else {
			if (obj == cornerWidget()) {
				auto p = this->addPlaylist();
				p->forceDrop(de);
			} else {
				currentPlayList()->forceDrop(de);
			}
			return true;
		}
	}
	return QTabWidget::eventFilter(obj, event);
}
开发者ID:ravloony,项目名称:Miam-Player,代码行数:26,代码来源:tabplaylist.cpp

示例14: if

bool CloudView::eventFilter(QObject *obj, QEvent *event)
{
    if (obj == mHeader) {
        static QPoint oldPos;
        if (event->type() == QEvent::MouseButtonPress) {
            QMouseEvent *ev = (QMouseEvent *)event;
            oldPos = ev->globalPos();

            return true;

        } else if (event->type() == QEvent::MouseMove) {
            QMouseEvent *ev = (QMouseEvent *)event;
            const QPoint delta = ev->globalPos() - oldPos;

            MainWindow *win = seafApplet->mainWindow();
            win->move(win->x() + delta.x(), win->y() + delta.y());

            oldPos = ev->globalPos();
            return true;
        }

    } else if (obj == mDropArea) {
        if (event->type() == QEvent::DragEnter) {
            QDragEnterEvent *ev = (QDragEnterEvent *)event;
            if (ev->mimeData()->hasUrls() && ev->mimeData()->urls().size() == 1) {
                const QUrl url = ev->mimeData()->urls().at(0);
                if (url.isLocalFile()) {
                    QString path = url.toLocalFile();
                    if (QFileInfo(path).isDir()) {
                        ev->acceptProposedAction();
                    }
                }
            }
            return true;
        } else if (event->type() == QEvent::Drop) {
            QDropEvent *ev = (QDropEvent *)event;
            const QUrl url = ev->mimeData()->urls().at(0);
            QString path = url.toLocalFile();
            showCreateRepoDialog(path);
            return true;
        }
    }

    return QWidget::eventFilter(obj, event);
}
开发者ID:datawerk,项目名称:seafile-client,代码行数:45,代码来源:cloud-view.cpp

示例15: sipConvertFromNewType

static PyObject *meth_QDropEvent_pos(PyObject *sipSelf, PyObject *sipArgs)
{
    PyObject *sipParseErr = NULL;

    {
        QDropEvent *sipCpp;

        if (sipParseArgs(&sipParseErr, sipArgs, "B", &sipSelf, sipType_QDropEvent, &sipCpp))
        {
            QPoint *sipRes;

            Py_BEGIN_ALLOW_THREADS
            sipRes = new QPoint(sipCpp->pos());
            Py_END_ALLOW_THREADS

            return sipConvertFromNewType(sipRes,sipType_QPoint,NULL);
        }
    }
开发者ID:ClydeMojura,项目名称:android-python27,代码行数:18,代码来源:sipQtGuiQDropEvent.cpp


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