Skip to content

QML and Qt Quick

Looking for The Bling Thing(tm)? Post here!
19.8k Topics 76.7k Posts
  • Automation IDs in QML

    Solved
    2
    0 Votes
    2 Posts
    137 Views
    A

    Found the answer to this question myself: It is by setting the objectName property:

    Control { objectName: "myAutomationId" }

    This will result in a Group automation element with automation ID myAutomationId.

    Found this by looking at https://github.com/faaxm/spix/blob/master/examples/RemoteCtrl/main.qml

  • Cannot edit QML files in Qt Creator

    Solved
    3
    0 Votes
    3 Posts
    160 Views
    A

    Thanks @sierdzio, if only! The solution for now is to open the QML file in Qt Design studio, available only from the Qt online installer on their website. I had missed the “open file” as opposed to “open project” button.

    Still weird, because as far as I can tell, Arch (I use arch, btw :) ) doesn’t have a repo for Design Studio, including in the AUR. And for sure, I had been editing QML files within Qt Creator before. Further, I have to open Design Studio from the command line, directly from the binary. But whatever, Design Studio totally suits my purpose here, so I’m happy (and ready to return to my backend lifestyle!). Will update if I figure out what I’m “really” doing wrong.

  • VTK not being recognized in QML

    Unsolved
    4
    0 Votes
    4 Posts
    434 Views
    M

    I have the same problem.

    My environment variables:

    VTK_DIR=C:/dev/github/VTK/build QML_IMPORT_PATH=C:/dev/github/VTK/build/lib/qml/Debug QT_DEBUG_PLUGINS=1 QML_IMPORT_TRACE=1 PATH=C:/dev/github/VTK/build/bin/Debug

    CMakeLists.txt

    cmake_minimum_required(VERSION 3.16) project(SphereView VERSION 0.1 LANGUAGES CXX) set(CMAKE_CXX_STANDARD_REQUIRED ON) set(QML_IMPORT_PATH C:/dev/github/VTK/build/lib/qml/${CMAKE_BUILD_TYPE} CACHE STRING "" FORCE) find_package(VTK REQUIRED COMPONENTS GUISupportQtQuick ) find_package(Qt6 6.5 REQUIRED COMPONENTS Quick) qt_standard_project_setup(REQUIRES 6.5) qt_add_executable(appSphereView main.cpp ) qt_add_qml_module(appSphereView URI SphereView VERSION 1.0 QML_FILES Main.qml SOURCES vtkitem.h vtkitem.cpp ) # Qt for iOS sets MACOSX_BUNDLE_GUI_IDENTIFIER automatically since Qt 6.1. # If you are developing for iOS or macOS you should consider setting an # explicit, fixed bundle identifier manually though. set_target_properties(appSphereView PROPERTIES # MACOSX_BUNDLE_GUI_IDENTIFIER com.example.appSphereView MACOSX_BUNDLE_BUNDLE_VERSION ${PROJECT_VERSION} MACOSX_BUNDLE_SHORT_VERSION_STRING ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR} MACOSX_BUNDLE TRUE WIN32_EXECUTABLE TRUE ) target_link_libraries(appSphereView PRIVATE Qt6::Quick ${VTK_LIBRARIES} ) include(GNUInstallDirs) install(TARGETS appSphereView BUNDLE DESTINATION . LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} )

    Main.qml

    import QtQuick 2.15 import QtQuick.Controls 2.15 import QtQuick.Window 2.15 import VTK 9.4 import com.example.sphereview 1.0 ApplicationWindow { visible: true width: 800 height: 600 title: qsTr("VTK Sphere App") color: palette.window SystemPalette { id: palette colorGroup: SystemPalette.Active } VTKRenderWindow { id: vtkwindow width: 800 height: 600 } VtkItem { objectName: "SphereView" anchors.fill: parent renderWindow: vtkwindow } }

    vtkitem.h

    // vtkitem.h #ifndef VTKITEM_H #define VTKITEM_H #include <QQuickVTKRenderItem.h> #include <vtkActor.h> #include <vtkPolyDataMapper.h> #include <vtkSphereSource.h> #include <vtkNew.h> class VtkItem : public QQuickVTKRenderItem { Q_OBJECT public: VtkItem(QQuickItem* parent = nullptr); private: vtkNew<vtkActor> actor; vtkNew<vtkPolyDataMapper> mapper; vtkNew<vtkSphereSource> sphere; }; #endif // VTKITEM_H

    vtkitem.cpp

    // vtkitem.cpp #include "vtkitem.h" VtkItem::VtkItem(QQuickItem* parent) : QQuickVTKRenderItem(parent) { sphere->SetRadius(5.0); mapper->SetInputConnection(sphere->GetOutputPort()); actor->SetMapper(mapper); renderer()->AddActor(actor); renderer()->ResetCamera(); renderer()->SetBackground(0.5, 0.5, 0.7); renderer()->SetBackground2(0.7, 0.7, 0.7); renderer()->SetGradientBackground(true); }

    main.cpp

    #include <QGuiApplication> #include <QQmlApplicationEngine> #include <vtkitem.h> int main(int argc, char *argv[]) { QQuickVTKRenderWindow::setupGraphicsBackend(); QGuiApplication app(argc, argv); QQmlApplicationEngine engine; // Register the custom VTK item with QML qmlRegisterType<VtkItem>("com.example.sphereview", 1.0, 0, "VtkItem"); QObject::connect( &engine, &QQmlApplicationEngine::objectCreationFailed, &app, []() { QCoreApplication::exit(-1); }, Qt::QueuedConnection); engine.loadFromModule("SphereView", "Main"); return app.exec(); }

    5dffe8ce-ee5f-4e99-80f6-b04c75f14e34-image.png
    fd48d1a7-e90b-4b61-a276-c6e7bf0d29b2-image.png

  • QML Qt.6.8.0beta2

    Unsolved
    4
    3 Votes
    4 Posts
    344 Views
    J

    I resolved this problem by clean install new built qt 6.8

  • Application don` t exit (maybe it cause qfuture?)

    Unsolved
    6
    0 Votes
    6 Posts
    219 Views
    Q

    @jsulm
    you can’t cancel qfuture that was launched via qtconcurrent::run, I ended up doing without using a thread at all, I just did connectToHost in restoreConnection without waiting, connected onConnect for the socket and processed all the logic there

  • module "QtMultimedia" is not installed

    Solved
    22
    0 Votes
    22 Posts
    8k Views
    JoeCFDJ

    If you look at the code here,
    https://doc.qt.io/qt-6/qml-qtmultimedia-videooutput.html

    The video output is used for media player. Where is your player? How do you code your player?

    property "source" does not exist in VideoOutput from
    https://doc.qt.io/qt-6/qml-qtmultimedia-videooutput-members.html

  • 0 Votes
    1 Posts
    174 Views
    No one has replied
  • 0 Votes
    7 Posts
    341 Views
    A

    @jsulm Oh, okay, thank you for your help. We can close this thread and mark it as solved.

  • Mnemonics in translated text

    Unsolved
    1
    0 Votes
    1 Posts
    62 Views
    No one has replied
  • textEdited signal for TextArea/TextEdit

    Unsolved
    5
    0 Votes
    5 Posts
    446 Views
    dheerendraD

    Bug is here https://bugreports.qt.io/browse/QTBUG-103718
    Fix is also under progress.

  • 0 Votes
    2 Posts
    215 Views
    Y

    I have encountered a similar problem, which has not been resolved. However, your example does not illustrate this issue.I test the example ,when myModel = newModel,print myModel.length =0

  • 0 Votes
    1 Posts
    86 Views
    No one has replied
  • Pickable model with QQuick3DGeometry

    Unsolved
    2
    1 Votes
    2 Posts
    222 Views
    B

    I have the same question. Did you ever figure out if Picking works with custom geometry? Thanks.

  • 0 Votes
    4 Posts
    2k Views
    V
    Canvas { id: canvas anchors { fill : parent } // antialiasing: true onPaint: { var ctx = canvas.getContext("2d") ctx.fillStyle = "white" ctx.fillRect(0, 0, canvas.width, canvas.height) }

    }

    // Adding a fillStyle might help !!!!

  • Controls.Windows dark mode

    Unsolved
    1
    0 Votes
    1 Posts
    133 Views
    No one has replied
  • Load the QML plugin automatically when application starts

    Unsolved
    3
    0 Votes
    3 Posts
    202 Views
    dheerendraD

    Thank you @Axel-Spoerl. QML file(MyPthinkSMain.qml) to load is present in the plugin itself. Code snippet

    QPluginLoader loader("/Users/dheeru/libs/India/Bengaluruu/PthinkS/QtExperts/libPthinkSUtilplugin.dylib"); loader.load(); const QUrl urlu"qrc:/India/Bengaluruu/PthinkS/QtExperts/MyPthinkSMain.qml"_qs); engine.load(url);

    The file qrc:/India/Bengaluruu/PthinkS/QtExperts/MyPthinkSMain.qml comes from the plugin libPthinkSUtilplugin.dylib itself. If I comment loader.load(), application does not show up window.

    As I understand plugin will be loaded once engine see the import statement in qml. Hope this is what you are describing. In my use case qml file itself comes from the plugin built using qt_add_qml_module.

  • UNSELECTED WHEN CLICK OUTSIDE A MOUSEAREA

    Unsolved
    1
    0 Votes
    1 Posts
    63 Views
    No one has replied
  • Question about pacthing functionalities to Qt

    Solved
    4
    0 Votes
    4 Posts
    180 Views
    SGaistS

    Good
    Then please make the thread as solved so other forum users may know a solution has been found :-)

  • Question About resource reference qml file from plugin dll

    Unsolved
    6
    0 Votes
    6 Posts
    360 Views
    dheerendraD

    @michael_su Finally solved this. Let me know if you need help.

  • QML FileDialog size

    Unsolved
    4
    0 Votes
    4 Posts
    223 Views
    K

    Some more info.
    I use kiosk-shell mode for weston (I need use one app in full screen mode). When I change it to desktop-shell, dialog size is normal, but I see maximize, minimize and close buttons for app.