Skip to content

QML and Qt Quick

Looking for The Bling Thing(tm)? Post here!
20.0k Topics 77.4k Posts
  • Restarting a QML application

    Solved
    3
    0 Votes
    3 Posts
    405 Views
    mzimmersM
    Thanks, @SGaist . It turns out that it was sufficient to recreate the engine. I modified the relevant portion of my code as follows: QQmlApplicationEngine *engine; qmlRegisterType<MyClass>("MyClass", 1, 0, "MyClass"); do { engine = new QQmlApplicationEngine; engine->rootContext()->setContextProperty("myClass", &myClass); engine->loadFromModule("restartQml", "Main"); currentExitCode = app.exec(); delete engine; } while (currentExitCode == MyClass::EXIT_CODE_REBOOT); return currentExitCode; } And it seems to work fine. I also discovered that I didn't need to pass in the QGuiApplication to my handler class; evidently this is provided to me via qApp: #include <qguiapplication.h> void MyClass::restartRequested() { qApp->exit( EXIT_CODE_REBOOT ); } Thank you for the help.
  • [Solved] Nesting QtObject in QtQuick

    8
    0 Votes
    8 Posts
    4k Views
    J
    The solution without the aliases, or Items, is definitely cleaner and more memory efficient. Unfortunately, Creator can't understand the syntax and provide autocomplete on the properties within the nestings! Using the Item / alias pattern resolves that.
  • 0 Votes
    20 Posts
    3k Views
    U
    hi thank u for reply @SGaist yes i have checked the file is present and also check the QtLocationPlugin.pri file for SOURCES += $$PWD/QGCMapEngine.cpp is present i just don't know what build flag is missing
  • Remember the last focused TextEdit and insert text inside it on clicking a button.

    Unsolved
    3
    0 Votes
    3 Posts
    269 Views
    F
    @GrecKo Thank you ! Indeed I can use that property :)
  • QML chart has border space instead of filling whole parent

    Unsolved
    7
    0 Votes
    7 Posts
    633 Views
    sierdzioS
    This might be a bug or "feature" of this component, then. You can file a report about it on Qt bug tracker.
  • "No QtMultimedia backends found" on MacOS with PySide 6.7.1

    Unsolved
    11
    0 Votes
    11 Posts
    3k Views
    SGaistS
    @SimonLiu Two options: Use an earlier version Build PySide6 yourself
  • Setting the model for a QQuickWidget

    Unsolved
    10
    0 Votes
    10 Posts
    1k Views
    _
    I ran into this issue myself when using QQuickWidget (since you're certainly going to want to be communicating between C++ and Qt Quick in that case). The original comment about setInitialProperties really triggered me, since that means there wasn't parity between QQuickWidget and QQuickView in a way that doesn't make sense. The same was true of the more modern loadFromModule pattern. So I created a couple patches to at least to try and rectify this in 6.9: https://codereview.qt-project.org/c/qt/qtdeclarative/+/586483/2 https://codereview.qt-project.org/c/qt/qtdeclarative/+/586520/1 But also I my case, that doesn't help me "today". I agree that using a QML Singleton is the correct solution over setting a context property, but that still led me to the issue that I wanted to do that the Modern/Correct way, but I didn't really understand from the docs how to get access to that Singleton from the C++ side. I found that this was the correct documentation page that explained that: https://doc.qt.io/qt-6/qtqml-cppintegration-exposecppstate.html But basically this is what the C++ code would look like: Singleton *singleton = engine->singletonInstance<Singleton *>("MyModule", "Singleton"); singleton->setThing(77);
  • QRhi render issues under Windows D3D11

    Unsolved
    2
    0 Votes
    2 Posts
    375 Views
    EthanTsaiE
    Debugging with RenderDoc, I found that the problem may occur in the "draw" function of the "QRhiCommandBuffer" class. In the original code, I called the "draw" function twice, namely: cb->draw(6, 1, 0, 0); cb->draw(3, 1, 6, 1); I intend to specify the "instanceCount", and the most important parameter - "firstInstance" (the "firstInstance" in the first call is 0, and 1 in the second) for each rendering. Through RenderDoc's debugging (as shown in the figure below), I found that these two calls correspond to two "glDrawArray" function events. The vertex number counts are 6 and 3, respectively, consistent with the numbers in my code, but "glDrawArrays" cannot specify instance ID. [image: 3fdfccc2-f30e-450e-afaf-6b203ac745a3.png] Furthermore, I changed the two "draw" function calls to one but changed the "instanceCount" to 2(draw two rectangle instances), and the firstInstance started from 0: cb->draw(6, 2, 0, 0); This time, the "draw" function corresponds to a "glDrawArraysInstanced" function event in RenderDoc, and the two graphics can use different object matrices. [image: c8968a62-361d-40e6-be47-8ef57cd6b8bb.png] Two rectangle instances with different model matrixes [image: e48dd912-2538-4e31-89eb-313b306e5601.png] So, It seems that when you want to draw multiple instances using the draw function, the parameter "firstInstance" should start from 0; the draw function can work adequately; is this a feature or a bug on the Windows platform? I noticed the note "firstInstance may not be supported when QRhi::BaseInstance feature is reported as not supported..." but I have checked the "QRhi::BaseInstance" feature in my platform, and it's said supported.
  • Static Library & use QML_ELEMENT to Expose the classes

    Unsolved
    3
    0 Votes
    3 Posts
    365 Views
    dheerendraD
    Further investigation on this. Some how we need to load the staticlibrary. On Linux 6.4.3 Q_INIT_RESOURCE(MyLib). This automatically loaded the libary & called qml_register type. Windows 6.61 - Q_INIT_RESOURCE(MyLib) - This gave me linker error saying that qInitResource_MyLib() is not defined. I just created the object from C++ class present in the library. It worked. We don't have to modify with extern "C". Not required.
  • Passing parameters to ffmpeg while using QtMultimedia

    Unsolved ffmpeg qmultimedia qml
    4
    1 Votes
    4 Posts
    1k Views
    J
    This will be fixed in the upcoming Qt 6.8 release, and is back-ported to 6.7.2. See https://bugreports.qt.io/browse/QTBUG-125006, which adds a check for the QT_FFMPEG_PROTOCOL_WHITELIST environment variable, which the user can set to override the whitelist with their own.
  • Text Width

    Moved Unsolved
    4
    0 Votes
    4 Posts
    381 Views
    G
    @Shankarlinga-M thank you i solve that
  • This topic is deleted!

    Unsolved
    1
    0 Votes
    1 Posts
    4 Views
    No one has replied
  • Problem with QML_ELEMENT for classes in subfolder of project

    Solved
    3
    0 Votes
    3 Posts
    349 Views
    shavS
    @Anumas Thanks for the answer! Added subfolder to INCLUDEPATH is help to me.
  • GrabToImage on scaled desktop for Windows

    Solved
    10
    0 Votes
    10 Posts
    840 Views
    Axel SpoerlA
    Thanks for sharing! It’s actually a bug, which the workaround clearly demonstrates.
  • QML Page Transition

    Unsolved
    2
    0 Votes
    2 Posts
    250 Views
    A
    Why are you closing the view, then? I don't think you need to. Instead of closing it, replace the current item in the StackView (like you do in stackView.push(Qt.resolvedUrl("qrc:/qml/MainRootWindow.qml"))) . So remove this screen.visible=false By default, StackView implements different transition for different events like popEnter, pushExit, ect. Here's an example of how to implement your own transitions: https://doc.qt.io/qt-6/qtquickcontrols-customize.html#customizing-stackview
  • Qml set context property for child item

    Unsolved
    1
    0 Votes
    1 Posts
    150 Views
    No one has replied
  • QML page transition

    Unsolved
    3
    0 Votes
    3 Posts
    292 Views
    C
    @GrecKo Thank you I will try.
  • Problem with adding another qml file

    Solved
    4
    0 Votes
    4 Posts
    324 Views
    A
    I found solution without creating resource. The pro file must by eddited like this with example in my example with Kafelek.qml After space write filename with extension in resource.files :) QT += quick SOURCES += \ main.cpp resources.files = main.qml Kafelek.qml resources.prefix = /$${TARGET} RESOURCES += resources # Additional import path used to resolve QML modules in Qt Creator's code model QML_IMPORT_PATH = # Additional import path used to resolve QML modules just for Qt Quick Designer QML_DESIGNER_IMPORT_PATH = # Default rules for deployment. qnx: target.path = /tmp/$${TARGET}/bin else: unix:!android: target.path = /opt/$${TARGET}/bin !isEmpty(target.path): INSTALLS += target DISTFILES += \ Kafelek.qml \ images/logo.png
  • [BUG] QML: Touch-Button not working inside Popup

    Unsolved
    3
    0 Votes
    3 Posts
    361 Views
    J
    Yes, that works. Thank you!
  • QGroundControl add a new QML page

    Unsolved
    2
    0 Votes
    2 Posts
    181 Views
    No one has replied