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


C++ QQuickItem::window方法代码示例

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


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

示例1: QObject

MnemonicAttached::MnemonicAttached(QObject *parent)
    : QObject(parent)
{
    QQuickItem *parentItem = qobject_cast<QQuickItem *>(parent);
    if (parentItem) {
        if (parentItem->window()) {
            m_window = parentItem->window();
            m_window->installEventFilter(this);
        }
        connect(parentItem, &QQuickItem::windowChanged, this,
                [this](QQuickWindow *window) {
            if (m_window) {
                QWindow *renderWindow = QQuickRenderControl::renderWindowFor(m_window);
                if (renderWindow) {
                    renderWindow->removeEventFilter(this);
                } else {
                    m_window->removeEventFilter(this);
                }
            }
            m_window = window;
            if (m_window) {
                QWindow *renderWindow = QQuickRenderControl::renderWindowFor(m_window);
                //renderWindow means the widget is rendering somewhere else, like a QQuickWidget
                if (renderWindow && renderWindow != m_window) {
                    renderWindow->installEventFilter(this);
                } else {
                    m_window->installEventFilter(this);
                }
            }
        });
    }
}
开发者ID:KDE,项目名称:kirigami,代码行数:32,代码来源:mnemonicattached.cpp

示例2:

QWindow *QuickTestEvent::eventWindow(QObject *item)
{
    QQuickItem *quickItem = qobject_cast<QQuickItem *>(item);
    if (quickItem)
        return quickItem->window();

    QQuickItem *testParentitem = qobject_cast<QQuickItem *>(parent());
    if (testParentitem)
        return testParentitem->window();
    return 0;
}
开发者ID:2gis,项目名称:2gisqt5android,代码行数:11,代码来源:quicktestevent.cpp

示例3: itemReparented

void QuickItemModel::itemReparented()
{
  QQuickItem *item = qobject_cast<QQuickItem*>(sender());
  if (!item || item->window() != m_window)
    return;

  QQuickItem* sourceParent = m_childParentMap.value(item);
  Q_ASSERT(sourceParent);
  const QModelIndex sourceParentIndex = indexForItem(sourceParent);

  QVector<QQuickItem*> &sourceSiblings = m_parentChildMap[sourceParent];
  QVector<QQuickItem*>::iterator sit = std::lower_bound(sourceSiblings.begin(), sourceSiblings.end(), item);
  Q_ASSERT(sit != sourceSiblings.end() && *sit == item);
  const int sourceRow = std::distance(sourceSiblings.begin(), sit);

  QQuickItem* destParent = item->parentItem();
  Q_ASSERT(destParent);
  const QModelIndex destParentIndex = indexForItem(destParent);

  QVector<QQuickItem*> &destSiblings = m_parentChildMap[destParent];
  QVector<QQuickItem*>::iterator dit = std::lower_bound(destSiblings.begin(), destSiblings.end(), item);
  const int destRow = std::distance(destSiblings.begin(), dit);

  beginMoveRows(sourceParentIndex, sourceRow, sourceRow, destParentIndex, destRow);
  destSiblings.insert(dit, item);
  sourceSiblings.erase(sit);
  m_childParentMap.insert(item, destParent);
  endMoveRows();
}
开发者ID:taehun32,项目名称:GammaRay,代码行数:29,代码来源:quickitemmodel.cpp

示例4: objectAdded

void QuickItemModel::objectAdded(QObject* obj)
{
  Q_ASSERT(thread() == QThread::currentThread());
  QQuickItem *item = qobject_cast<QQuickItem*>(obj);
  if (!item)
    return;

  if (item->window() != m_window)
    return; // item for a different scene

  if (m_childParentMap.contains(item))
    return; // already known

  QQuickItem *parentItem = item->parentItem();
  if (parentItem) {
    // add parent first, if we don't know that yet
    if (!m_childParentMap.contains(parentItem))
      objectAdded(parentItem);
  }

  connectItem(item);

  const QModelIndex index = indexForItem(parentItem);
  Q_ASSERT(index.isValid() || !parentItem);

  QVector<QQuickItem*> &children = m_parentChildMap[parentItem];
  QVector<QQuickItem*>::iterator it = std::lower_bound(children.begin(), children.end(), obj);
  const int row = std::distance(children.begin(), it);

  beginInsertRows(index, row, row);
  children.insert(it, item);
  m_childParentMap.insert(item, parentItem);
  endInsertRows();
}
开发者ID:taehun32,项目名称:GammaRay,代码行数:34,代码来源:quickitemmodel.cpp

示例5: open

void IconDialog::open()
{
    if (m_dialog->isVisible()) {
        return;
    }

    QQuickItem *parentItem = qobject_cast<QQuickItem *>(parent());
    QQuickWindow *parentWindow = (parentItem ? parentItem->window() : qobject_cast<QQuickWindow *>(parent()));

    if (m_modality == Qt::NonModal) {
        m_dialog->setModal(false);
    } else if (m_modality == Qt::WindowModal) {
        m_dialog->winId(); // needed to get the windowHandle prior to showing
        m_dialog->windowHandle()->setTransientParent(parentWindow);
        m_dialog->setModal(false); // WindowModal does not unset the overall modality
    } else if (m_modality == Qt::ApplicationModal) {
        m_dialog->setModal(true);
    }

    m_dialog->setWindowModality(m_modality);

    m_dialog->setup(KIconLoader::NoGroup, KIconLoader::Application, false, m_iconSize, m_user);

    m_dialog->show();
}
开发者ID:KDE,项目名称:kdeclarative,代码行数:25,代码来源:icondialog.cpp

示例6: extractQImage

QImage ImageHandler::extractQImage(QObject *imageObj, int offsetX, int offsetY, int width, int height)
{
    QImage img;
#if defined(QZXING_QML)
#if QT_VERSION >= 0x050000
    QQuickItem *item = qobject_cast<QQuickItem *>(imageObj);

    if (!item || !item->window()->isVisible()) {
        return QImage();
    }

    QTime timer;
    timer.start();
    QSharedPointer<QQuickItemGrabResult> result = item->grabToImage();
    pendingGrabbersLocker.lockForWrite();
    pendingGrabbers << result.data();
    pendingGrabbersLocker.unlock();

    connect(result.data(), &QQuickItemGrabResult::ready, this, &ImageHandler::imageGrabberReady);
    while (timer.elapsed() < 1000) {
        pendingGrabbersLocker.lockForRead();
        if (!pendingGrabbers.contains(result.data())) {
            pendingGrabbersLocker.unlock();
            break;
        }
        pendingGrabbersLocker.unlock();
        qApp->processEvents();
        QThread::yieldCurrentThread();
    }
    img = result->image();
#else
    QGraphicsObject *item = qobject_cast<QGraphicsObject*>(imageObj);

    if (!item) {
        return QImage();
    }

    img = QImage(item->boundingRect().size().toSize(), QImage::Format_RGB32);
    img.fill(QColor(255, 255, 255).rgb());
    QPainter painter(&img);
    QStyleOptionGraphicsItem styleOption;
    item->paint(&painter, &styleOption);
#endif
#endif //defined(QZXING_QML)

    if (offsetX < 0)
        offsetX = 0;
    if (offsetY < 0)
        offsetY = 0;
    if (width < 0)
        width = 0;
    if (height < 0)
        height = 0;

    if (offsetX || offsetY || width || height)
        return img.copy(offsetX, offsetY, width, height);
    else
        return img;
}
开发者ID:ideum,项目名称:omeka-everywhere,代码行数:59,代码来源:ImageHandler.cpp

示例7: itemUpdated

void QuickItemModel::itemUpdated()
{
  QQuickItem *item = qobject_cast<QQuickItem*>(sender());
  if (!item || item->window() != m_window)
    return;

  const QModelIndex left = indexForItem(item);
  const QModelIndex right = left.sibling(left.row(), columnCount() - 1);
  emit dataChanged(left, right);
}
开发者ID:taehun32,项目名称:GammaRay,代码行数:10,代码来源:quickitemmodel.cpp

示例8: if

static QQmlPrivate::AutoParentResult qquickitem_autoParent(QObject *obj, QObject *parent)
{
    // When setting a parent (especially during dynamic object creation) in QML,
    // also try to set up the analogous item/window relationship.
    QQuickItem *parentItem = qmlobject_cast<QQuickItem *>(parent);
    if (parentItem) {
        QQuickItem *item = qmlobject_cast<QQuickItem *>(obj);
        if (item) {
            // An Item has another Item
            item->setParentItem(parentItem);
            return QQmlPrivate::Parented;
        } else if (parentItem->window()) {
            QQuickWindow *win = qmlobject_cast<QQuickWindow *>(obj);
            if (win) {
                // A Window inside an Item should be transient for that item's window
                win->setTransientParent(parentItem->window());
                return QQmlPrivate::Parented;
            }
        }
        return QQmlPrivate::IncompatibleObject;
    } else {
        QQuickWindow *parentWindow = qmlobject_cast<QQuickWindow *>(parent);
        if (parentWindow) {
            QQuickWindow *win = qmlobject_cast<QQuickWindow *>(obj);
            if (win) {
                // A Window inside a Window should be transient for it
                win->setTransientParent(parentWindow);
                return QQmlPrivate::Parented;
            } else {
                QQuickItem *item = qmlobject_cast<QQuickItem *>(obj);
                if (item) {
                    // The parent of an Item inside a Window is actually the implicit content Item
                    item->setParentItem(parentWindow->contentItem());
                    return QQmlPrivate::Parented;
                }
            }
            return QQmlPrivate::IncompatibleObject;
        }
    }
    return QQmlPrivate::IncompatibleParent;
}
开发者ID:tizenorg,项目名称:platform.upstream.qtdeclarative,代码行数:41,代码来源:qquickitemsmodule.cpp

示例9: eventWindow

QWindow* TestService::eventWindow(QObject* _item)
{
    QQuickItem* item = qobject_cast<QQuickItem*>(_item);
    if (item && item->window())
        return item->window();

    QWindow* window = qobject_cast<QQuickWindow*>(_item);
    if (!window && _item->parent())
        window = eventWindow(_item->parent());
    if (!window)
        window = qobject_cast<QQuickWindow*>(m_targetWindow);
    if (window)
    {
        window->requestActivate();
        std::cout << window->title().toStdString();
        return window;
    }
    item = qobject_cast<QQuickItem*>(m_targetWindow);
    if (item)
        return item->window();
    return 0;
}
开发者ID:BitcoinKinetics,项目名称:cpp-ethereum,代码行数:22,代码来源:TestService.cpp

示例10: setLoopCount

QT_BEGIN_NAMESPACE

QQuickAnimatorProxyJob::QQuickAnimatorProxyJob(QAbstractAnimationJob *job, QObject *item)
    : m_controller(0)
    , m_job(job)
    , m_internalState(State_Stopped)
    , m_jobManagedByController(false)
{
    m_isRenderThreadProxy = true;
    m_animation = qobject_cast<QQuickAbstractAnimation *>(item);

    setLoopCount(job->loopCount());

    // Instead of setting duration to job->duration() we need to set it to -1 so that
    // it runs as long as the job is running on the render thread. If we gave it
    // an explicit duration, it would be stopped, potentially stopping the RT animation
    // prematurely.
    // This means that the animation driver will tick on the GUI thread as long
    // as the animation is running on the render thread, but this overhead will
    // be negligiblie compared to animating and re-rendering the scene on the render thread.
    m_duration = -1;

    QObject *ctx = findAnimationContext(m_animation);
    if (!ctx) {
        qWarning("QtQuick: unable to find animation context for RT animation...");
        return;
    }

    QQuickWindow *window = qobject_cast<QQuickWindow *>(ctx);
    if (window) {
        setWindow(window);
    } else {
        QQuickItem *item = qobject_cast<QQuickItem *>(ctx);
        if (item->window())
            setWindow(item->window());
        connect(item, SIGNAL(windowChanged(QQuickWindow*)), this, SLOT(windowChanged(QQuickWindow*)));
    }
}
开发者ID:venkatarajasekhar,项目名称:Qt,代码行数:38,代码来源:qquickanimatorjob.cpp

示例11: QColorDialogHelper

QPlatformColorDialogHelper *QQuickQColorDialog::helper()
{
    QQuickItem *parentItem = qobject_cast<QQuickItem *>(parent());
    if (parentItem)
        m_parentWindow = parentItem->window();

    if (!m_dlgHelper) {
        m_dlgHelper = new QColorDialogHelper();
        connect(m_dlgHelper, SIGNAL(currentColorChanged(QColor)), this, SLOT(setCurrentColor(QColor)));
        connect(m_dlgHelper, SIGNAL(colorSelected(QColor)), this, SLOT(setColor(QColor)));
        connect(m_dlgHelper, SIGNAL(accept()), this, SLOT(accept()));
        connect(m_dlgHelper, SIGNAL(reject()), this, SLOT(reject()));
    }

    return m_dlgHelper;
}
开发者ID:SchleunigerAG,项目名称:WinEC7_Qt5.3.1_Fixes,代码行数:16,代码来源:qquickqcolordialog.cpp

示例12: QMessageBoxHelper

QPlatformDialogHelper *QQuickQMessageBox::helper()
{
    QQuickItem *parentItem = qobject_cast<QQuickItem *>(parent());
    if (parentItem)
        m_parentWindow = parentItem->window();

    if (!QQuickAbstractMessageDialog::m_dlgHelper) {
        QMessageBoxHelper* helper = new QMessageBoxHelper();
        QQuickAbstractMessageDialog::m_dlgHelper = helper;
        // accept() shouldn't be emitted.  reject() happens only if the dialog is
        // dismissed by closing the window rather than by one of its button widgets.
        connect(helper, SIGNAL(accept()), this, SLOT(accept()));
        connect(helper, SIGNAL(reject()), this, SLOT(reject()));
        connect(helper, SIGNAL(clicked(QPlatformDialogHelper::StandardButton,QPlatformDialogHelper::ButtonRole)),
            this, SLOT(click(QPlatformDialogHelper::StandardButton,QPlatformDialogHelper::ButtonRole)));
    }

    return QQuickAbstractMessageDialog::m_dlgHelper;
}
开发者ID:RobinWuDev,项目名称:Qt,代码行数:19,代码来源:qquickqmessagebox.cpp

示例13: sendKeyToFocusItem

void MockupKeyEventDispatcher::sendKeyToFocusItem(const QString &keyText)
{
    if (!m_focusItem) {
        return;
    }

    // special handling for Backspace (send a QKeyEvent to the receiving text element)
    if (keyText == QString("\x7F")) {
        QKeyEvent event(QEvent::KeyPress, Qt::Key_Backspace, Qt::NoModifier);
        QQuickItem *receiver = qobject_cast<QQuickItem *>(m_focusItem);
        receiver->window()->sendEvent(receiver, &event);

    // send the typed character to the text field using QInputMethodEvent::setCommitString()
    } else {
        QInputMethodEvent ev;
        ev.setCommitString(keyText);
        QCoreApplication::sendEvent(m_focusItem,&ev);
    }
}
开发者ID:ganquan0910,项目名称:qt5virtualkeyboard,代码行数:19,代码来源:mockupkeyeventdispatcher.cpp

示例14: usePlatformNativeDialog

QPlatformFontDialogHelper *QQuickPlatformFontDialog::helper()
{
    QQuickItem *parentItem = qobject_cast<QQuickItem *>(parent());
    if (parentItem)
        m_parentWindow = parentItem->window();

    if ( !m_dlgHelper && QGuiApplicationPrivate::platformTheme()->
            usePlatformNativeDialog(QPlatformTheme::FontDialog) ) {
        m_dlgHelper = static_cast<QPlatformFontDialogHelper *>(QGuiApplicationPrivate::platformTheme()
           ->createPlatformDialogHelper(QPlatformTheme::FontDialog));
        if (!m_dlgHelper)
            return m_dlgHelper;
        connect(m_dlgHelper, SIGNAL(accept()), this, SLOT(accept()));
        connect(m_dlgHelper, SIGNAL(reject()), this, SLOT(reject()));
        connect(m_dlgHelper, SIGNAL(currentFontChanged(QFont)), this, SLOT(setFont(QFont)));
        connect(m_dlgHelper, SIGNAL(fontSelected(QFont)), this, SLOT(setFont(QFont)));
    }

    return m_dlgHelper;
}
开发者ID:Sagaragrawal,项目名称:2gisqt5android,代码行数:20,代码来源:qquickplatformfontdialog.cpp

示例15: usePlatformNativeDialog

QPlatformFileDialogHelper *QQuickPlatformFileDialog::helper()
{
    QQuickItem *parentItem = qobject_cast<QQuickItem *>(parent());
    if (parentItem)
        m_parentWindow = parentItem->window();

    if ( !m_dlgHelper && QGuiApplicationPrivate::platformTheme()->
            usePlatformNativeDialog(QPlatformTheme::FileDialog) ) {
        m_dlgHelper = static_cast<QPlatformFileDialogHelper *>(QGuiApplicationPrivate::platformTheme()
           ->createPlatformDialogHelper(QPlatformTheme::FileDialog));
        if (!m_dlgHelper)
            return m_dlgHelper;
        m_dlgHelper->setOptions(m_options);
        connect(m_dlgHelper, SIGNAL(directoryEntered(QUrl)), this, SIGNAL(folderChanged()));
        connect(m_dlgHelper, SIGNAL(filterSelected(QString)), this, SIGNAL(filterSelected()));
        connect(m_dlgHelper, SIGNAL(accept()), this, SLOT(accept()));
        connect(m_dlgHelper, SIGNAL(reject()), this, SLOT(reject()));
    }

    return m_dlgHelper;
}
开发者ID:RobinWuDev,项目名称:Qt,代码行数:21,代码来源:qquickplatformfiledialog.cpp


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