Skip to content

QML and Qt Quick

Looking for The Bling Thing(tm)? Post here!
20.0k Topics 77.4k Posts
  • QFileSystemModel and Listview to list directories

    Unsolved
    8
    0 Votes
    8 Posts
    2k Views
    fcarneyF
    Use a DelegateModel in between the filesystem model and the ListView. Edit: You can specify the root index in the delegate model.
  • Selecting item in QML TreeView does not change isSelected of item

    Solved
    2
    0 Votes
    2 Posts
    501 Views
    ocgltdO
    Problem is inconsistency in how QML names its methods. Some are "isSelected" (eg ROW), or "isExpanded" (ITEM), but item uses "selected" instead of "isSelected"
  • Cant assign axisYRight to LineSeries created at runtime

    Unsolved
    1
    0 Votes
    1 Posts
    165 Views
    No one has replied
  • Building a TreeView example in QML only

    Solved
    4
    0 Votes
    4 Posts
    272 Views
    ocgltdO
    It seems that you can't do it - the model must descend from QAbstractItemModel so I had to create a C++ descendant first (implementing pur e virtual functions) and then it I could proceed.
  • Is it ok when I create QML qtquick file for every UI block?

    Unsolved
    2
    0 Votes
    2 Posts
    210 Views
    dheerendraD
    There is nothing like a wrong. It is better to create the individual loadable qml files. You should load or create objects from qml which are not visible. If one screen itself is very complete, it is better to break them into smaller pieces and use them.
  • Qt linguist not get text from c++ code.

    Moved Unsolved
    9
    0 Votes
    9 Posts
    519 Views
    SeeLookS
    Hi! @S_max07 You might wrap a text in XML file with syntax recognized by lupdate, i.e.: •<?xml version="1.0"> <someKey>translate("someContext", "text to translate")</someKey> when that key is handled by C++, trim it and then translate: QXmlStreamReader xml; if (xml.name() == QLatin1String("someKey")) auto key = QApplication::translate("someContext", xml.readElementText() .replace(QLatin1String("translate(\"someContext\", \""), QString()) .replace(QLatin1String("\")"), QString()).toLocal8Bit()); and invoke lupdate which also looks up for *.xml extensions: lupdate -extensions cpp,h,qml,xml -recursive src_dir xml_dir -ts some_file.ts
  • scrollview with Flicable Animation in QML

    Moved Unsolved
    2
    0 Votes
    2 Posts
    157 Views
    A
    Hi SGaist how to implement horzintal scroll with Flicable Animation .Kindly help me Thank you
  • qtquickcompiler

    Unsolved
    6
    1 Votes
    6 Posts
    1k Views
    KH-219DesignK
    That's a super interesting link from @sierdzio . I was unaware of QML_DISK_CACHE_PATH and QML_DISABLE_DISK_CACHE environment variables! They are apparently fairly recent additions. Apparently, prior to Qt 5.15.0, disk cache path cannot vary. Since then, it can vary based on environment variable QML_DISK_CACHE_PATH.
  • This topic is deleted!

    Unsolved
    1
    0 Votes
    1 Posts
    12 Views
    No one has replied
  • otherway aroun: how to call qml function from javascript file?

    Solved
    2
    0 Votes
    2 Posts
    226 Views
    fcarneyF
    Its not in the same scope. How would it even know it exists? Either pass the function or the object to the JS function: Component.onCompleted: { JS.testFromJS(mouseAreaID); } ... function testFromJS(obj) { obj.testFunction() }
  • This topic is deleted!

    Locked Unsolved
    2
    0 Votes
    2 Posts
    7 Views
  • Detect "is_on_top" in QML StackView. How?

    Moved Solved
    2
    0 Votes
    2 Posts
    200 Views
    B
    Solution found. Issue closed. Inside of SScreenLogin: property string pObjectName: "SScreenLogin"; id: oRoot; objectName: oRoot.pObjectName; And inside of JS script: if (oStackView.currentItem.objectName == oRoot.pObjectName) { On top } else { Not on top }
  • i need to change the order of row elements in gridview

    Unsolved
    5
    0 Votes
    5 Posts
    523 Views
    fcarneyF
    I would say don't do this with index: property var list: [...] ListView { model: list delegate: Item { list[index] } } So now I get what you mean. Yes, in that case modelData makes sense.
  • Qml ScrollView, mouse click

    Unsolved
    2
    0 Votes
    2 Posts
    410 Views
    DiracsbracketD
    @mrdebug Can't you use a MouseArea that covers your view and on the click handler do something like: onClicked: { timer.restart() mouse.accepted = false }
  • QML2_IMPORT_PATH, Build Environment and project sharing

    Solved
    9
    0 Votes
    9 Posts
    6k Views
    B
    @raven-worx Thank you for this extended proposal. I would like my app to support a dynamic path to where our Qt Module will be hosted. Hence I created something as follows: in my app.pro CUSTOM QML LIBRARY #import custom qml mibrary DEVELOPMENT_PATH = $$PWD CUSTOM_QML_LIBRARY_PATH = $$DEVELOPMENT_PATH/relative/path/to/proj5106_hmi_graphic_library include($$CUSTOM_QML_LIBRARY_PATH/Custom_QML_Library/Custom_QML_Library.pri) in the cpp file creating the qml engine: // CUSTOM QML LIBRARY #include <Custom_QML_Library.h> And then: // Import CUSTOM QML LIBRARY import_custom_qml_libary(*m_pEngine); In our custom module folder: in the .pri file: Additional import path used to resolve QML modules in Qt Creator's code model QML_IMPORT_PATH += $$CUSTOM_QML_LIBRARY_PATH DEFINES += DEVELOPMENT_PATH_MACRO="\"$${DEVELOPMENT_PATH}\"" CUSTOM_QML_LIBRARY_PATH_MACRO="\"$${CUSTOM_QML_LIBRARY_PATH}\"" INCLUDEPATH += $$CUSTOM_QML_LIBRARY_PATH/Custom_QML_Library and in the Custom_QML_Library.h file: #pragma once #include <QQmlApplicationEngine> void import_custom_qml_libary(QQmlApplicationEngine &_qQmlApplicationEngine); void import_custom_qml_libary(QQmlApplicationEngine &_qQmlApplicationEngine) { // If working dir path contains the project dir path // Then we consider we execute from the development environment // use the CUSTOM_QML_LIBRARY_PATH variable // Else look for the CUSTOM QML Lib Pat deployed in third_parties subfolder // by default QString development_pwd = DEVELOPMENT_PATH_MACRO; QString pwd = QDir::currentPath(); if (pwd.contains(development_pwd) == true) { qDebug () << "Adding Custom QML Library from " << CUSTOM_QML_LIBRARY_PATH_MACRO; _qQmlApplicationEngine.addImportPath(CUSTOM_QML_LIBRARY_PATH_MACRO); } else { qDebug () << "Adding Custom QML Library from " << pwd + "/third_parties"; _qQmlApplicationEngine.addImportPath(pwd + "/third_parties"); } qDebug() << _qQmlApplicationEngine.importPathList(); } At deployment time, we shall create the /third_parties sub folder and copy our module content their. Seems ok for our current solution. Thank you all. I hope this can be useful for someone. Regards, Bill
  • Can find TreeView module in QML

    Solved
    5
    0 Votes
    5 Posts
    674 Views
    ocgltdO
    I installed 5.x kit, so Qt Controls 1.x SHOULD be installed. I closed Qt Creator and reopened and now warning is gone. Strange... But I am still unclear on something. is TreeView included with QtQuick Controls 2.x ? If not, does that mean TreeView is deprecated and will be dropped in Qt 6? (Should I avoid using TreeView ?)
  • Plugin type not recognized

    Unsolved
    4
    0 Votes
    4 Posts
    522 Views
    R
    @jsulm Thank you very much. Here is my button widget import QtQuick 2.12 import QtQuick.Controls 2.12 Button { id: button /** sets Button Text visible*/ property bool bIsButtonTextVisible: true .... Here is my CheckBox Widget import QtQuick 2.0 import QtQuick.Controls 2.12 Rectangle{ id :checkBox /** checkbox current state checked / unchecked */ property bool checked: true ... Here is my cpp code #include "widgets_plugin.h" #include <qqml.h> void WidgetsPlugin::registerTypes(const char *uri) { // @uri com.mycompany.qmlcomponents qmlRegisterType(QUrl("qrc:/EDSButton/Source/component/ButtonWidget.qml"), uri, 1, 0, "ButtonWidget"); qmlRegisterType(QUrl("qrc:/EDSCheckBox/Source/component/CheckBoxWidget.qml"), uri, 1, 0, "CheckBoxWidget"); } Here is my header file #ifndef WIDGETS_PLUGIN_H #define WIDGETS_PLUGIN_H #include <QQmlExtensionPlugin> class WidgetsPlugin : public QQmlExtensionPlugin { Q_OBJECT Q_PLUGIN_METADATA(IID QQmlExtensionInterface_iid) public: void registerTypes(const char *uri) override; }; #endif // WIDGETS_PLUGIN_H All this packaged into a library. Here is my application cpp #include <QGuiApplication> #include <QQmlApplicationEngine> int main(int argc, char *argv[]) { QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling); QGuiApplication app(argc, argv); QQmlApplicationEngine engine; const QUrl url(QStringLiteral("qrc:/main.qml")); QObject::connect(&engine, &QQmlApplicationEngine::objectCreated, &app, [url](QObject *obj, const QUrl &objUrl) { if (!obj && url == objUrl) QCoreApplication::exit(-1); }, Qt::QueuedConnection); engine.load(url); return app.exec(); } And here is my main qml import QtQuick 2.9 import QtQuick.Window 2.2 //import "qrc:/EDSCheckBox/Source/component" import "C:\Users\RadiumBall\Downloads\EDSCheckBoxComponent\EDS_Component\debug\Widgets.dll" Window { width: 640 height: 480 visible: true title: qsTr("Hello World") CheckBoxWidget{ id : testCheckBox rCheckboxConfigureHeight: 24 rCheckboxConfigureWidth: 24 rCheckboxConfigureRadius: 1 rCheckboxConfigureImgHeight: 16 rCheckboxConfigureImgWidth: 16 sCheckBoxLabel: "CheckBox" } I am doing two mistakes here, one is w.r.t importing the library and other complier throws me error 'CheckBoxWidget' is not a type. PS: The CheckBoxWidget qml works perfectly fine when included directly but fails when included as a library. Please help.
  • TextEdit: Richtext to Standard text conversion problem

    Unsolved
    4
    0 Votes
    4 Posts
    652 Views
    C
    @fcarney yes you are right. QTextDocument did do the job far better than the one provided on the QML side. I just had to write the following on C++ side Q_INVOKABLE QString returnPlainText(QString s) { QTextDocument td; td.setHtml(s); return td.toPlainText(); } and invoke the function from QML like this import QtQuick 2.15 Rectangle { function onTextChanging(){ console.log(QtTest2.returnPlainText(xText.text)) } TextEdit{ id: xText height:300 width: 500 textFormat:TextEdit.RichText onTextChanged: onTextChanging() } } I will raise the QML part issue to the bugs though
  • QML debugging stops not on breakpoints

    Unsolved
    1
    0 Votes
    1 Posts
    223 Views
    No one has replied
  • Problems with putting video stream in Qt QML using deepstream pipeline

    Solved qml camera
    2
    0 Votes
    2 Posts
    510 Views
    SGaistS
    Hi, AFAIK, it's the one provided in QtMultimedia.