本文整理汇总了C++中QQuickWindow::contentItem方法的典型用法代码示例。如果您正苦于以下问题:C++ QQuickWindow::contentItem方法的具体用法?C++ QQuickWindow::contentItem怎么用?C++ QQuickWindow::contentItem使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QQuickWindow
的用法示例。
在下文中一共展示了QQuickWindow::contentItem方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: create
QuickWindowNodeInstance::Pointer QuickWindowNodeInstance::create(QObject *object)
{
QQuickWindow *quickWindow = qobject_cast<QQuickWindow*>(object);
Q_ASSERT(quickWindow);
Pointer instance(new QuickWindowNodeInstance(quickWindow));
instance->setHasContent(anyItemHasContent(quickWindow->contentItem()));
quickWindow->contentItem()->setFlag(QQuickItem::ItemHasContents, true);
static_cast<QQmlParserStatus*>(quickWindow->contentItem())->classBegin();
instance->populateResetHashes();
QQuickItemPrivate *privateItem = static_cast<QQuickItemPrivate*>(QObjectPrivate::get(quickWindow->contentItem()));
if (privateItem->window) {
if (!privateItem->parentItem)
QQuickWindowPrivate::get(privateItem->window)->parentlessItems.remove(quickWindow->contentItem());
privateItem->derefWindow();
privateItem->window = 0;
}
return instance;
}
示例2: adjust
void Highlight::adjust()
{
if (!m_item)
return;
bool success = false;
m_transform = m_item->itemTransform(0, &success);
if (!success)
m_transform = QTransform();
setSize(QSizeF(m_item->width(), m_item->height()));
qreal scaleFactor = 1;
QPointF originOffset = QPointF(0,0);
QQuickWindow *view = m_item->window();
if (view->contentItem()) {
scaleFactor = view->contentItem()->scale();
originOffset -= view->contentItem()->position();
}
// The scale transform for the overlay needs to be cancelled
// as the Item's transform which will be applied to the painter
// takes care of it.
parentItem()->setScale(1/scaleFactor);
setPosition(originOffset);
update();
}
示例3: defaultFocus
void tst_applicationwindow::defaultFocus()
{
QQmlEngine engine;
QQmlComponent component(&engine);
component.loadUrl(testFileUrl("defaultFocus.qml"));
QObject* created = component.create();
QScopedPointer<QObject> cleanup(created);
Q_UNUSED(cleanup);
QVERIFY(created);
QQuickWindow* window = qobject_cast<QQuickWindow*>(created);
QVERIFY(window);
window->show();
window->requestActivate();
QVERIFY(QTest::qWaitForWindowActive(window));
QVERIFY(QGuiApplication::focusWindow() == window);
QQuickItem* contentItem = window->contentItem();
QVERIFY(contentItem);
QVERIFY(contentItem->hasActiveFocus());
// A single item in an ApplicationWindow with focus: true should receive focus.
QQuickItem* item = findItem<QQuickItem>(window->contentItem(), "item");
QVERIFY(item);
QVERIFY(item->hasFocus());
QVERIFY(item->hasActiveFocus());
}
示例4: component
void tst_applicationwindow::activeFocusOnTab2()
{
QQmlEngine engine;
QQmlComponent component(&engine);
component.loadUrl(testFileUrl("activefocusontab.qml"));
QObject* created = component.create();
QScopedPointer<QObject> cleanup(created);
QVERIFY(created);
QQuickWindow* window = qobject_cast<QQuickWindow*>(created);
QVERIFY(window);
window->show();
window->requestActivate();
QVERIFY(QTest::qWaitForWindowActive(window));
QVERIFY(QGuiApplication::focusWindow() == window);
QQuickItem* contentItem = window->contentItem();
QVERIFY(contentItem);
QVERIFY(contentItem->hasActiveFocus());
QQuickItem* item = findItem<QQuickItem>(window->contentItem(), "sub2");
QVERIFY(item);
QVERIFY(!item->hasActiveFocus());
// BackTab: contentItem->sub2
QKeyEvent key(QEvent::KeyPress, Qt::Key_Tab, Qt::ShiftModifier, "", false, 1);
QGuiApplication::sendEvent(window, &key);
QVERIFY(key.isAccepted());
item = findItem<QQuickItem>(window->contentItem(), "sub2");
QVERIFY(item);
QVERIFY(item->hasActiveFocus());
// BackTab: sub2->sub1
key = QKeyEvent(QEvent::KeyPress, Qt::Key_Tab, Qt::ShiftModifier, "", false, 1);
QGuiApplication::sendEvent(window, &key);
QVERIFY(key.isAccepted());
item = findItem<QQuickItem>(window->contentItem(), "sub1");
QVERIFY(item);
QVERIFY(item->hasActiveFocus());
// BackTab: sub1->sub2
key = QKeyEvent(QEvent::KeyPress, Qt::Key_Tab, Qt::ShiftModifier, "", false, 1);
QGuiApplication::sendEvent(window, &key);
QVERIFY(key.isAccepted());
item = findItem<QQuickItem>(window->contentItem(), "sub2");
QVERIFY(item);
QVERIFY(item->hasActiveFocus());
}
示例5: setItem
void Highlight::setItem(QQuickItem *item)
{
if (m_item)
m_item->disconnect(this);
if (item) {
connect(item, SIGNAL(xChanged()), SLOT(adjust()));
connect(item, SIGNAL(yChanged()), SLOT(adjust()));
connect(item, SIGNAL(widthChanged()), SLOT(adjust()));
connect(item, SIGNAL(heightChanged()), SLOT(adjust()));
connect(item, SIGNAL(rotationChanged()), SLOT(adjust()));
connect(item, SIGNAL(transformOriginChanged(TransformOrigin)),
SLOT(adjust()));
}
QQuickWindow *view = item->window();
QQuickItem * contentItem = view->contentItem();
if (contentItem) {
connect(contentItem, SIGNAL(xChanged()), SLOT(adjust()));
connect(contentItem, SIGNAL(yChanged()), SLOT(adjust()));
connect(contentItem, SIGNAL(widthChanged()), SLOT(adjust()));
connect(contentItem, SIGNAL(heightChanged()), SLOT(adjust()));
connect(contentItem, SIGNAL(rotationChanged()), SLOT(adjust()));
connect(contentItem, SIGNAL(transformOriginChanged(TransformOrigin)),
SLOT(adjust()));
}
m_item = item;
setContentsSize(view->size());
adjust();
}
示例6: onXdgToplevelCreated
void Compositor::onXdgToplevelCreated(QWaylandXdgToplevel *toplevel, QWaylandXdgSurface *shellSurface)
//void Compositor::onXdgSurfaceCreated(QWaylandXdgSurface *shellSurface)
{
unsigned int windowId = mNextWindowId++;
QWaylandSurface *surface = shellSurface->surface();
qDebug() << Q_FUNC_INFO << "windowId" << windowId << surface;
QQuickWindow *defaultOutputWindow = static_cast<QQuickWindow*>(defaultOutput()->window());
CompositorWindow *window = new CompositorWindow(windowId, defaultOutputWindow->contentItem());
window->setOutput(defaultOutput()); //useful ?
window->setFlag(QQuickItem::ItemIsFocusScope, true);
// window->setUseTextureAlpha(true);
window->initialize(shellSurface);
window->setSize(surface->size());
window->setTouchEventsEnabled(true);
mWindows.insert(windowId, window);
connect(window, &CompositorWindow::readyChanged, this, &Compositor::windowIsReady);
connect(window, &QWaylandQuickItem::surfaceDestroyed, this, &Compositor::onSurfaceDestroyed);
window->sendWindowIdToClient();
}
示例7: eventFilter
bool QuickInspector::eventFilter(QObject *receiver, QEvent *event)
{
if (event->type() == QEvent::MouseButtonRelease) {
QMouseEvent *mouseEv = static_cast<QMouseEvent*>(event);
if (mouseEv->button() == Qt::LeftButton &&
mouseEv->modifiers() == (Qt::ControlModifier | Qt::ShiftModifier)) {
QQuickWindow *window = qobject_cast<QQuickWindow*>(receiver);
if (window && window->contentItem()) {
QQuickItem *item = recursiveChiltAt(window->contentItem(), mouseEv->pos());
m_probe->selectObject(item);
}
}
}
return QObject::eventFilter(receiver, event);
}
示例8: registerQuickItem
void WindowManager::registerQuickItem( QQuickItem* item )
{
if ( !item ) return;
QQuickWindow *window = item->window();
if (window) {
QQuickItem *contentItem = window->contentItem();
contentItem->setAcceptedMouseButtons( Qt::LeftButton );
contentItem->removeEventFilter( this );
contentItem->installEventFilter( this );
}
}
示例9: show
void QQuickPopupWindow::show()
{
qreal posx = x();
qreal posy = y();
// transientParent may not be a QQuickWindow when embedding into widgets
if (QWindow *tp = transientParent()) {
if (m_parentItem) {
QPointF pos = m_parentItem->mapToItem(m_parentItem->window()->contentItem(), QPointF(posx, posy));
posx = pos.x();
posy = pos.y();
}
QPoint tlwOffset = tp->mapToGlobal(QPoint());
posx += tlwOffset.x();
posy += tlwOffset.y();
} else if (m_parentItem && m_parentItem->window()) {
QPoint offset;
QQuickWindow *quickWindow = m_parentItem->window();
QWindow *renderWindow = QQuickRenderControl::renderWindowFor(quickWindow, &offset);
QPointF pos = m_parentItem->mapToItem(quickWindow->contentItem(), QPointF(posx, posy));
posx = pos.x();
posy = pos.y();
QPoint parentWindowOffset = (renderWindow ? renderWindow : quickWindow)->mapToGlobal(QPoint());
posx += offset.x() + parentWindowOffset.x();
posy += offset.y() + parentWindowOffset.y();
}
if (m_contentItem) {
qreal initialWidth = qMax(qreal(1), m_contentItem->width());
qreal initialHeight = qMax(qreal(1), m_contentItem->height());
setGeometry(posx, posy, initialWidth, initialHeight);
} else {
setPosition(posx, posy);
}
emit geometryChanged();
if (!qobject_cast<QQuickPopupWindow *>(transientParent())) { // No need for parent menu windows
if (QQuickWindow *w = qobject_cast<QQuickWindow *>(transientParent())) {
if (QQuickItem *mg = w->mouseGrabberItem())
mg->ungrabMouse();
} else if (m_parentItem && m_parentItem->window()) {
if (QQuickItem *mg = m_parentItem->window()->mouseGrabberItem())
mg->ungrabMouse();
}
}
QQuickWindow::show();
setMouseGrabEnabled(true); // Needs to be done after calling show()
setKeyboardGrabEnabled(true);
}
示例10: queryAccessibleInterface
QAccessibleInterface *QAccessibleQuickItem::parent() const
{
QQuickItem *parent = item()->parentItem();
if (parent) {
QQuickWindow *window = item()->window();
// Jump out to the scene widget if the parent is the root item.
// There are two root items, QQuickWindow::rootItem and
// QQuickView::declarativeRoot. The former is the true root item,
// but is not a part of the accessibility tree. Check if we hit
// it here and return an interface for the scene instead.
if (window && (parent == window->contentItem())) {
return QAccessible::queryAccessibleInterface(window);
} else {
return QAccessible::queryAccessibleInterface(parent);
}
}
return 0;
}
示例11: benchmarkCreation
void tst_StatusIndicator::benchmarkCreation()
{
QFETCH(bool, active);
QQuickWindow window;
window.resize(240, 240);
window.create();
QQmlEngine engine;
// TODO: fix
QString path = QString::fromLatin1(SRCDIR "/LotsOfIndicators%1.qml").arg(active ? "Active" : "Inactive");
QQmlComponent component(&engine, QUrl::fromLocalFile(path));
QVERIFY2(!component.isError(), qPrintable(component.errorString()));
QVERIFY(component.isReady());
QBENCHMARK {
QQuickItem *root = qobject_cast<QQuickItem*>(component.create());
root->setParentItem(window.contentItem());
window.grabWindow();
}
}
示例12: 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;
}
示例13: show
void popupWindow::show() {
qreal posx = x();
qreal posy = y();
// transientParent may not be a QQuickWindow when embedding into widgets
if (QWindow *tp = transientParent()) {
if (m_pParentItem) {
QPointF pos = m_pParentItem->mapToItem(m_pParentItem->window()->contentItem(), QPointF());
posx = pos.x();
posy = pos.y();
}
QPoint tlwOffset = tp->mapToGlobal(QPoint());
posx += tlwOffset.x();
posy += tlwOffset.y();
} else if (m_pParentItem && m_pParentItem->window()) {
QPoint offset;
QQuickWindow *quickWindow = m_pParentItem->window();
QWindow *renderWindow = QQuickRenderControl::renderWindowFor(quickWindow, &offset);
QPointF pos = m_pParentItem->mapToItem(quickWindow->contentItem(), QPointF(posx, posy));
posx = pos.x();
posy = pos.y();
QPoint parentWindowOffset = (renderWindow ? renderWindow : quickWindow)->mapToGlobal(QPoint());
posx += offset.x() + parentWindowOffset.x();
posy += offset.y() + parentWindowOffset.y();
}
setGeometry(posx + m_xOffset, posy + m_yOffset, width(), height());
emit geometryChanged();
m_mouseMoved = false;
QQuickWindow::show();
setMouseGrabEnabled(true); // Needs to be done after calling show()
//setKeyboardGrabEnabled(true);
}
示例14: main
//.........这里部分代码省略.........
commandManager.InjectDependency(&keywordsSuggestor);
commandManager.InjectDependency(&settingsModel);
commandManager.InjectDependency(&recentDirectorieModel);
commandManager.InjectDependency(&spellCheckerService);
commandManager.InjectDependency(&spellCheckSuggestionModel);
commandManager.InjectDependency(&metadataSaverService);
commandManager.InjectDependency(&telemetryService);
commandManager.InjectDependency(&updateService);
commandManager.InjectDependency(&logsModel);
commandManager.InjectDependency(&localLibrary);
commandManager.InjectDependency(&metadataIOCoordinator);
commandManager.InjectDependency(&pluginManager);
commandManager.InjectDependency(&languagesModel);
commandManager.InjectDependency(&colorsModel);
commandManager.InjectDependency(&autoCompleteService);
commandManager.InjectDependency(&imageCachingService);
commandManager.InjectDependency(&replaceModel);
commandManager.InjectDependency(&deleteKeywordsModel);
commandManager.InjectDependency(&helpersQmlWrapper);
commandManager.ensureDependenciesInjected();
keywordsSuggestor.initSuggestionEngines();
// other initializations
secretsManager.setMasterPasswordHash(appSettings.value(Constants::MASTER_PASSWORD_HASH, "").toString());
uploadInfoRepository.initFromString(appSettings.value(Constants::UPLOAD_HOSTS, "").toString());
recentDirectorieModel.deserializeFromSettings(appSettings.value(Constants::RECENT_DIRECTORIES, "").toString());
commandManager.connectEntitiesSignalsSlots();
languagesModel.initFirstLanguage();
languagesModel.loadLanguages();
telemetryService.setInterfaceLanguage(languagesModel.getCurrentLanguage());
qmlRegisterType<Helpers::ClipboardHelper>("xpiks", 1, 0, "ClipboardHelper");
qmlRegisterType<QMLExtensions::TriangleElement>("xpiks", 1, 0, "TriangleElement");
QQmlApplicationEngine engine;
Helpers::GlobalImageProvider *globalProvider = new Helpers::GlobalImageProvider(QQmlImageProviderBase::Image);
QMLExtensions::CachingImageProvider *cachingProvider = new QMLExtensions::CachingImageProvider(QQmlImageProviderBase::Image);
cachingProvider->setImageCachingService(&imageCachingService);
QQmlContext *rootContext = engine.rootContext();
rootContext->setContextProperty("artItemsModel", &artItemsModel);
rootContext->setContextProperty("artworkRepository", &artworkRepository);
rootContext->setContextProperty("combinedArtworks", &combinedArtworksModel);
rootContext->setContextProperty("appSettings", &appSettings);
rootContext->setContextProperty("secretsManager", &secretsManager);
rootContext->setContextProperty("undoRedoManager", &undoRedoManager);
rootContext->setContextProperty("keywordsSuggestor", &keywordsSuggestor);
rootContext->setContextProperty("settingsModel", &settingsModel);
rootContext->setContextProperty("filteredArtItemsModel", &filteredArtItemsModel);
rootContext->setContextProperty("helpersWrapper", &helpersQmlWrapper);
rootContext->setContextProperty("recentDirectories", &recentDirectorieModel);
rootContext->setContextProperty("metadataIOCoordinator", &metadataIOCoordinator);
rootContext->setContextProperty("pluginManager", &pluginManager);
rootContext->setContextProperty("pluginsWithActions", &pluginsWithActions);
rootContext->setContextProperty("warningsModel", &warningsModel);
rootContext->setContextProperty("languagesModel", &languagesModel);
rootContext->setContextProperty("i18", &languagesModel);
rootContext->setContextProperty("Colors", &colorsModel);
rootContext->setContextProperty("acSource", &autoCompleteModel);
rootContext->setContextProperty("replaceModel", &replaceModel);
#ifdef QT_DEBUG
QVariant isDebug(true);
#else
QVariant isDebug(false);
#endif
rootContext->setContextProperty("debug", isDebug);
engine.addImageProvider("global", globalProvider);
engine.addImageProvider("cached", cachingProvider);
LOG_DEBUG << "About to load main view...";
engine.load(QUrl(QStringLiteral("qrc:/main.qml")));
LOG_DEBUG << "Main view loaded";
pluginManager.getUIProvider()->setQmlEngine(&engine);
QQuickWindow *window = qobject_cast<QQuickWindow *>(engine.rootObjects().at(0));
pluginManager.getUIProvider()->setRoot(window->contentItem());
#ifdef QT_DEBUG
if (argc > 1) {
QList<QUrl> pathes;
for (int i = 1; i < argc; ++i) {
pathes.append(QUrl::fromLocalFile(QString::fromUtf8(argv[i])));
}
commandManager.addInitialArtworks(pathes);
}
#endif
commandManager.afterConstructionCallback();
return app.exec();
}