本文整理汇总了C++中QDropEvent::acceptProposedAction方法的典型用法代码示例。如果您正苦于以下问题:C++ QDropEvent::acceptProposedAction方法的具体用法?C++ QDropEvent::acceptProposedAction怎么用?C++ QDropEvent::acceptProposedAction使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QDropEvent
的用法示例。
在下文中一共展示了QDropEvent::acceptProposedAction方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: event
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);
}
示例2: eventFilter
bool AssemblyBrowser::eventFilter(QObject* o, QEvent* e) {
if(o == ui) {
if (e->type() == QEvent::DragEnter || e->type() == QEvent::Drop) {
QDropEvent* de = (QDropEvent*)e;
const QMimeData* md = de->mimeData();
const GObjectMimeData* gomd = qobject_cast<const GObjectMimeData*>(md);
if (gomd != NULL) {
if (e->type() == QEvent::DragEnter) {
de->acceptProposedAction();
} else {
QApplication::changeOverrideCursor(Qt::ArrowCursor);//setting arrow cursor on Linux
QString err = tryAddObject(gomd->objPtr.data());
if(!err.isEmpty()) {
QMessageBox::critical(ui, tr("Error!"), err);
}
}
}
}
}
return false;
}
示例3: eventFilter
//.........这里部分代码省略.........
s = 1.0;
s = qMax<qreal>(s, 0.0);
player->setSpeed(s);
return true;
}
if (ao && ao->isAvailable()) {
qreal v = player->audio()->volume();
if (v > 0.5)
v -= 0.1;
else if (v > 0.1)
v -= 0.05;
else
v -= 0.025;
player->audio()->setVolume(v);
qDebug("vol = %.3f", player->audio()->volume());
}
}
break;
case Qt::Key_O: {
if (modifiers == Qt::ControlModifier) {
//TODO: emit a signal so we can use custome dialogs?
openLocalFile();
} else/* if (m == Qt::NoModifier) */{
emit showNextOSD();
}
}
break;
case Qt::Key_Left:
qDebug("<-");
player->seekBackward();
break;
case Qt::Key_Right:
qDebug("->");
player->seekForward();
break;
case Qt::Key_M:
if (player->audio()) {
player->audio()->setMute(!player->audio()->isMute());
}
break;
case Qt::Key_R: {
VideoRenderer* renderer = player->renderer();
VideoRenderer::OutAspectRatioMode r = renderer->outAspectRatioMode();
renderer->setOutAspectRatioMode(VideoRenderer::OutAspectRatioMode(((int)r+1)%2));
}
break;
case Qt::Key_T: {
QWidget *w = qApp->activeWindow();
if (!w)
return false;
Qt::WindowFlags wf = w->windowFlags();
if (wf & Qt::WindowStaysOnTopHint) {
qDebug("Window not stays on top");
w->setWindowFlags(wf & ~Qt::WindowStaysOnTopHint);
} else {
qDebug("Window stays on top");
w->setWindowFlags(wf | Qt::WindowStaysOnTopHint);
}
//call setParent() when changing the flags, causing the widget to be hidden
w->show();
}
break;
case Qt::Key_F1:
help();
break;
default:
return false;
}
break;
}
case QEvent::DragEnter:
case QEvent::DragMove: {
QDropEvent *e = static_cast<QDropEvent*>(event);
e->acceptProposedAction();
}
break;
case QEvent::Drop: {
QDropEvent *e = static_cast<QDropEvent*>(event);
QString path = e->mimeData()->urls().first().toLocalFile();
player->stop();
player->load(path);
player->play();
e->acceptProposedAction();
}
break;
case QEvent::GraphicsSceneContextMenu: {
QGraphicsSceneContextMenuEvent *e = static_cast<QGraphicsSceneContextMenuEvent*>(event);
showMenu(e->screenPos());
}
break;
case QEvent::ContextMenu: {
QContextMenuEvent *e = static_cast<QContextMenuEvent*>(event);
showMenu(e->globalPos());
}
break;
default:
return false;
}
return true; //false: for text input
}
示例4: if
bool BE::Contacts::eventFilter(QObject *o, QEvent *e)
{
if (o == m_ui->filter) {
if (e->type() == QEvent::KeyPress)
if (static_cast<QKeyEvent*>(e)->key() == Qt::Key_Down)
m_ui->contacts->setFocus();
return false;
}
if (o == m_ui->contacts) {
if (e->type() == QEvent::KeyPress) {
QKeyEvent *ke = static_cast<QKeyEvent*>(e);
if (ke->key() == Qt::Key_Up && !m_ui->contacts->currentIndex().row()) {
m_ui->filter->setFocus();
return true;
} else if (ke->key() == Qt::Key_Delete) {
removeCurrentContact();
return true;
}
}
return false;
}
if (!m_currentContact)
return false;
switch (e->type()) {
case QEvent::DragEnter:
case QEvent::DragMove:
case QEvent::Drop: {
if (o != m_ui2->photo)
return false;
QDropEvent *de = static_cast<QDropEvent*>(e);
if (!de->mimeData())
return false;
QList<QUrl> urls = de->mimeData()->urls();
if (urls.isEmpty())
return false;
QUrl url = urls.first();
if (
#if QT_VERSION >= QT_VERSION_CHECK(4, 8, 0)
url.isLocalFile()
#else
(url.scheme() == QLatin1String("file"))
#endif
&& QImageReader(url.path()).canRead()) {
if (e->type() == QEvent::Drop)
importPhoto(url.path());
else
de->acceptProposedAction();
}
return false;
}
case QEvent::KeyPress: {
const int key = static_cast<QKeyEvent*>(e)->key();
if (key == Qt::Key_Delete && o == m_ui2->photo) { // reset photo
if (m_currentContact)
m_currentContact->setData(QString(), Gui::AbookAddressbook::Photo);
m_ui2->photo->setPixmap(m_incognitoPic);
}
else if (key == Qt::Key_Escape && o != m_ui2->photo)
if (QLabel *l = qobject_cast<QLabel*>(o)) {
setText(l, l->text());
return true; // prevent closing the dialog!
}
}
default:
return false;
}
return false;
}