本文整理汇总了C++中QQuickWindow类的典型用法代码示例。如果您正苦于以下问题:C++ QQuickWindow类的具体用法?C++ QQuickWindow怎么用?C++ QQuickWindow使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了QQuickWindow类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Q_D
void QQuickPinchArea::clearPinch()
{
Q_D(QQuickPinchArea);
d->touchPoints.clear();
if (d->inPinch) {
d->inPinch = false;
QPointF pinchCenter = mapFromScene(d->sceneLastCenter);
QQuickPinchEvent pe(pinchCenter, d->pinchLastScale, d->pinchLastAngle, d->pinchRotation);
pe.setStartCenter(d->pinchStartCenter);
pe.setPreviousCenter(pinchCenter);
pe.setPreviousAngle(d->pinchLastAngle);
pe.setPreviousScale(d->pinchLastScale);
pe.setStartPoint1(mapFromScene(d->sceneStartPoint1));
pe.setStartPoint2(mapFromScene(d->sceneStartPoint2));
pe.setPoint1(mapFromScene(d->lastPoint1));
pe.setPoint2(mapFromScene(d->lastPoint2));
emit pinchFinished(&pe);
if (d->pinch && d->pinch->target())
d->pinch->setActive(false);
}
d->pinchStartDist = 0;
d->pinchActivated = false;
d->initPinch = false;
d->pinchRejected = false;
d->stealMouse = false;
d->id1 = -1;
QQuickWindow *win = window();
if (win && win->mouseGrabberItem() == this)
ungrabMouse();
setKeepMouseGrab(false);
}
示例2: Q_D
void QQuickMouseArea::mouseReleaseEvent(QMouseEvent *event)
{
Q_D(QQuickMouseArea);
d->stealMouse = false;
if (!d->enabled && !d->pressed) {
QQuickItem::mouseReleaseEvent(event);
} else {
d->saveEvent(event);
setPressed(event->button(), false);
if (!d->pressed) {
// no other buttons are pressed
#ifndef QT_NO_DRAGANDDROP
if (d->drag)
d->drag->setActive(false);
#endif
// If we don't accept hover, we need to reset containsMouse.
if (!acceptHoverEvents())
setHovered(false);
QQuickWindow *w = window();
if (w && w->mouseGrabberItem() == this)
ungrabMouse();
setKeepMouseGrab(false);
}
}
d->doubleClick = false;
}
示例3:
QImage_ *windowGrabWindow(QQuickWindow_ *win)
{
QQuickWindow *qwin = reinterpret_cast<QQuickWindow *>(win);
QImage *image = new QImage;
*image = qwin->grabWindow().convertToFormat(QImage::Format_ARGB32_Premultiplied);
return image;
}
示例4: connect
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();
}
示例5: main
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
QStandardItemModel model;
model.appendRow(new QStandardItem("Norway"));
model.appendRow(new QStandardItem("Netherlands"));
model.appendRow(new QStandardItem("New Zealand"));
model.appendRow(new QStandardItem("Namibia"));
model.appendRow(new QStandardItem("Nicaragua"));
model.appendRow(new QStandardItem("North Korea"));
model.appendRow(new QStandardItem("Northern Cyprus "));
model.appendRow(new QStandardItem("Sweden"));
model.appendRow(new QStandardItem("Denmark"));
QStringList strings;
strings << "Norway" << "Sweden" << "Denmark";
QQmlApplicationEngine engine;
engine.rootContext()->setContextProperty("standardmodel", &model);
engine.rootContext()->setContextProperty("stringmodel", strings);
engine.load(QUrl("main.qml"));
QObject *topLevel = engine.rootObjects().value(0);
QQuickWindow *window = qobject_cast<QQuickWindow *>(topLevel);
if ( !window ) {
qWarning("Error: Your root item has to be a Window.");
return -1;
}
window->show();
return app.exec();
}
示例6: QTransform
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();
}
示例7: createTexture
void createTexture()
{
if (bufferRef)
bufferRef.destroyTexture();
bufferRef = nextBuffer;
QQuickWindow *window = static_cast<QQuickWindow *>(surface->mainOutput()->window());
// If the next buffer is NULL do not delete the current texture. If the client called
// attach(0) the surface is going to be unmapped anyway, if instead the client attached
// a valid buffer but died before we got here we want to keep the old buffer around
// in case some destroy animation is run.
if (bufferRef) {
delete texture;
if (bufferRef.isShm()) {
texture = window->createTextureFromImage(bufferRef.image());
} else {
QQuickWindow::CreateTextureOptions opt = 0;
if (surface->useTextureAlpha()) {
opt |= QQuickWindow::TextureHasAlphaChannel;
}
texture = window->createTextureFromId(bufferRef.createTexture(), surface->size(), opt);
}
texture->bind();
}
update = false;
}
示例8: Q_ASSERT
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;
}
示例9: setTargetWindow
void TestService::setTargetWindow(QObject* _window)
{
QQuickWindow* window = qobject_cast<QQuickWindow*>(_window);
if (window)
m_targetWindow = window;
window->requestActivate();
}
示例10: component
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());
}
示例11: Q_UNUSED
// A very simple implementation where we assume that there's only one window and that it's a
// QQuickWindow. Thus the id parameter is irrelevant.
//
// Idea: Make the id contain the objectName of the QQuickWindow once we care about a multi-display
// compositor?
// Strictly speaking that could be the actual QWindow::winId(), but that's mostly a
// meaningless arbitrary number.
QImage WindowScreenshotProvider::requestImage(const QString &id, QSize *size, const QSize &requestedSize)
{
Q_UNUSED(id);
Q_UNUSED(requestedSize);
QWindowList windows = QGuiApplication::topLevelWindows();
if (windows.count() != 1) {
size->rwidth() = 0;
size->rheight() = 0;
return QImage();
}
QQuickWindow *quickWindow = qobject_cast<QQuickWindow *>(windows[0]);
if (!quickWindow) {
size->rwidth() = 0;
size->rheight() = 0;
return QImage();
}
QImage image = quickWindow->grabWindow();
size->rwidth() = image.width();
size->rheight() = image.height();
return image;
}
示例12: qDebug
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();
}
示例13: main
QT_BEGIN_NAMESPACE
#ifndef QT_NO_WIDGETS
#define Application QApplication
#else
#define Application QGuiApplication
#endif
int main(int argc, char *argv[])
{
Application app(argc, argv);
QScreen* sc = app.primaryScreen();
if(sc){
sc->setOrientationUpdateMask(Qt::LandscapeOrientation
| Qt::PortraitOrientation
| Qt::InvertedLandscapeOrientation
| Qt::InvertedPortraitOrientation);
}
QQmlApplicationEngine engine(QUrl("qrc:/main.qml"));
QObject *topLevel = engine.rootObjects().value(0);
QQuickWindow *window = qobject_cast<QQuickWindow *>(topLevel);
if ( !window ) {
qWarning("Error: Your root item has to be a Window.");
return -1;
}
window->showFullScreen();
return app.exec();
}
示例14: main
int main(int argc, char ** argv)
{
QApplication app(argc, argv);
qmlRegisterType<Hider>("com.ics.demo", 1, 0, "Hider");
int rc = 0;
QQmlEngine engine;
QQmlComponent *component = new QQmlComponent(&engine);
QObject::connect(&engine, SIGNAL(quit()), QCoreApplication::instance(), SLOT(quit()));
component->loadUrl(QUrl("../../Source/main.qml"));
Hider::image_provider = new ImageProvider;
engine.addImageProvider("images", Hider::image_provider);
if (!component->isReady() ) {
qWarning("%s", qPrintable(component->errorString()));
return -1;
}
QObject *topLevel = component->create();
QQuickWindow *window = qobject_cast<QQuickWindow *>(topLevel);
QSurfaceFormat surfaceFormat = window->requestedFormat();
window->setFormat(surfaceFormat);
window->show();
rc = app.exec();
delete component;
return rc;
}
示例15: visibilityChanged
void QQuickWindowAttached::windowChanged(QQuickWindow *window)
{
if (window != m_window) {
QQuickWindow* oldWindow = m_window;
m_window = window;
if (oldWindow)
oldWindow->disconnect(this);
if (!window)
return; // No values to get, therefore nothing to emit
if (!oldWindow || window->visibility() != oldWindow->visibility())
emit visibilityChanged();
if (!oldWindow || window->isActive() != oldWindow->isActive())
emit activeChanged();
if (!oldWindow || window->activeFocusItem() != oldWindow->activeFocusItem())
emit activeFocusItemChanged();
emit contentItemChanged();
// QQuickWindowQmlImpl::visibilityChanged also exists, and window might even
// be QQuickWindowQmlImpl, but that's not what we are connecting to.
// So this is actual window state rather than a buffered or as-requested one.
// If we used the metaobject connect syntax there would be a warning:
// QMetaObjectPrivate::indexOfSignalRelative - QMetaObject::indexOfSignal:
// signal visibilityChanged(QWindow::Visibility) from QQuickWindow redefined in QQuickWindowQmlImpl
connect(window, &QQuickWindow::visibilityChanged,
this, &QQuickWindowAttached::visibilityChanged);
connect(window, &QQuickWindow::activeChanged,
this, &QQuickWindowAttached::activeChanged);
connect(window, &QQuickWindow::activeFocusItemChanged,
this, &QQuickWindowAttached::activeFocusItemChanged);
}
}