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


C++ QDropEvent::possibleActions方法代码示例

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


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

示例1: eventFilter

/** 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

示例2: eventFilter

bool HashBox::eventFilter(QObject* object, QEvent* event)
{
	if (object == dropWidget) {
		if (event->type() == QEvent::DragEnter) {
			QDragEnterEvent* dragEnterEvent = static_cast<QDragEnterEvent*>(event);
			if (dragEnterEvent) {
				/* print out mimeType */
				showFormats("HashBox::dragEnterEvent", dragEnterEvent->mimeData()->formats());

				if (dragEnterEvent->mimeData()->hasUrls()) {
					std::cerr << "HashBox::dragEnterEvent() Accepting Urls" << std::endl;
					dragEnterEvent->acceptProposedAction();
				} else {
					std::cerr << "HashBox::dragEnterEvent() No Urls" << std::endl;
				}
			}
		} else if (event->type() == QEvent::Drop) {
			QDropEvent* dropEvent = static_cast<QDropEvent*>(event);
			if (dropEvent) {
				if (Qt::CopyAction & dropEvent->possibleActions()) {
					/* print out mimeType */
					showFormats("HashBox::dropEvent", dropEvent->mimeData()->formats());

					QStringList files;

					if (dropEvent->mimeData()->hasUrls()) {
						std::cerr << "HashBox::dropEvent() Urls:" << std::endl;

						QList<QUrl> urls = dropEvent->mimeData()->urls();
						QList<QUrl>::iterator uit;
						for (uit = urls.begin(); uit != urls.end(); ++uit) {
							QString localpath = uit->toLocalFile();
							std::cerr << "Whole URL: " << uit->toString().toStdString() << std::endl;
							std::cerr << "or As Local File: " << localpath.toStdString() << std::endl;

							if (localpath.isEmpty() == false) {
								//Check that the file does exist and is not a directory
								QDir dir(localpath);
								if (dir.exists()) {
									std::cerr << "HashBox::dropEvent() directory not accepted." << std::endl;
									QMessageBox mb(tr("Drop file error."), tr("Directory can't be dropped, only files are accepted."), QMessageBox::Information, QMessageBox::Ok, 0, 0, this);
									mb.exec();
								} else if (QFile::exists(localpath)) {
									files.push_back(localpath);
								} else {
									std::cerr << "HashBox::dropEvent() file does not exists."<< std::endl;
									QMessageBox mb(tr("Drop file error."), tr("File not found or file name not accepted."), QMessageBox::Information, QMessageBox::Ok, 0, 0, this);
									mb.exec();
								}
							}
						}
					}

					addAttachments(files,mDefaultTransferFlags);

					dropEvent->setDropAction(Qt::CopyAction);
					dropEvent->accept();
				} else {
					std::cerr << "HashBox::dropEvent() Rejecting uncopyable DropAction" << std::endl;
				}
			}
		}
	}
	// pass the event on to the parent class
	return QScrollArea::eventFilter(object, event);
}
开发者ID:MrKID,项目名称:RetroShare,代码行数:66,代码来源:HashBox.cpp


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