diff options
Diffstat (limited to 'examples')
-rw-r--r-- | examples/qml/doc/src/qml-extending.qdoc | 19 | ||||
-rw-r--r-- | examples/quick/scenegraph/sgengine/window.cpp | 8 |
2 files changed, 24 insertions, 3 deletions
diff --git a/examples/qml/doc/src/qml-extending.qdoc b/examples/qml/doc/src/qml-extending.qdoc index 8f44e4f506..f25b75ed29 100644 --- a/examples/qml/doc/src/qml-extending.qdoc +++ b/examples/qml/doc/src/qml-extending.qdoc @@ -63,6 +63,25 @@ loads and runs the QML snippet shown at the beginning of this page. */ /*! +\example referenceexamples/extended +\title Extending QML - Extension Objects Example +\brief Extension Objects +\ingroup qmlextendingexamples + +This example builds on: +\list +\li \l {Extending QML - Adding Types Example} +\endlist + +Shows how to use \l qmlRegisterExtendedType() to provide an \l {Registering +Extension Objects}{extension object} to a \l QLineEdit without modifying or +subclassing. The QML engine instantiates a \l QLineEdit and sets a property that +only exists on the extension type. The extension type performs calls on the \l +QLineEdit that otherwise will not be accessible to the QML engine. + +*/ + +/*! \example referenceexamples/properties \title Extending QML - Object and List Property Types Example \brief Exporting C++ Properties diff --git a/examples/quick/scenegraph/sgengine/window.cpp b/examples/quick/scenegraph/sgengine/window.cpp index 9af4029165..bc371a38f6 100644 --- a/examples/quick/scenegraph/sgengine/window.cpp +++ b/examples/quick/scenegraph/sgengine/window.cpp @@ -47,6 +47,7 @@ #include <QSGTransformNode> #include <QScreen> #include <QVariantAnimation> +#include <QOpenGLFunctions> class Item { public: @@ -213,13 +214,14 @@ void Window::initialize() m_sgRenderer->setClearColor(QColor(32, 32, 32)); // With QSGEngine::createTextureFromId + QOpenGLFunctions glFuncs(m_context.data()); GLuint glTexture; - glGenTextures(1, &glTexture); - glBindTexture(GL_TEXTURE_2D, glTexture); + glFuncs.glGenTextures(1, &glTexture); + glFuncs.glBindTexture(GL_TEXTURE_2D, glTexture); QImage smile = QImage(":/scenegraph/sgengine/face-smile.png").scaled(48, 48, Qt::KeepAspectRatio, Qt::SmoothTransformation); smile = smile.convertToFormat(QImage::Format_RGBA8888_Premultiplied); Q_ASSERT(!smile.isNull()); - glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, smile.width(), smile.height(), 0, GL_RGBA, GL_UNSIGNED_BYTE, smile.constBits()); + glFuncs.glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, smile.width(), smile.height(), 0, GL_RGBA, GL_UNSIGNED_BYTE, smile.constBits()); m_smileTexture.reset(m_sgEngine->createTextureFromId(glTexture, smile.size(), QFlag(QSGEngine::TextureOwnsGLTexture | QSGEngine::TextureHasAlphaChannel))); // With QSGEngine::createTextureFromImage |