Skip to content

QML and Qt Quick

Looking for The Bling Thing(tm)? Post here!
20.0k Topics 77.4k Posts
  • i need to change the order of row elements in gridview

    Unsolved
    5
    0 Votes
    5 Posts
    525 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
    523 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
    654 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
    224 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.
  • Hai, I am using virtual key board but there is some issue in auto scroll.

    Unsolved
    1
    0 Votes
    1 Posts
    194 Views
    No one has replied
  • Unable to define a list of values shared across multiple QML files using a Singleton

    Solved
    5
    0 Votes
    5 Posts
    572 Views
    raven-worxR
    @JL-SABATIER said in Unable to define a list of values shared across multiple QML files using a Singleton: I may use enum values instead of that singleton. But I need to share these definitions among all QML pages, and to do so, I guess I'll have to declare this enum on the model side, in C++, no, just import the url the QML file with the enum is in
  • qml dummy property

    Unsolved
    4
    0 Votes
    4 Posts
    571 Views
    P
    Thank for your reply. Sorry maybe I describe my problem wrong, or I don't understand your answer. I set contex propertyin C++: engine.rootContext()->setContextProperty("PP_IP", QVariant("192.168.100.195")); When I run my program, and show "mypage.qml" - everythink is OK - console log IP "192.168.100.195" . Now when I use qmlscene to show "mypage.qml" , the property PP_IP is not set (because C++ code not run). So I want set these variable by dummy data. How can I do this? I need print IP adress 192.168.100.195 - when I run mypage.qml from qmlscene. Can you post dummydata/exmaple.qml for me? Thank you for your patience!! //mypage.qml Rectangle{ Component.onCompleted: { console.log("Test: "+PP_IP) //print IP adress } }
  • Cant access model data from dialog

    Solved
    4
    0 Votes
    4 Posts
    438 Views
    sierdzioS
    Nice, thanks for posting the solution, it might help others, too!
  • QML plugin using Ahead of Time compiler

    Unsolved
    1
    0 Votes
    1 Posts
    168 Views
    No one has replied
  • This topic is deleted!

    Unsolved
    1
    0 Votes
    1 Posts
    20 Views
    No one has replied
  • Why can't I import a Javascript file to my QML code

    Unsolved
    2
    0 Votes
    2 Posts
    161 Views
    Volodymyr14V
    import "jscripts/u_js.js" as Ujs
  • accessing "child" (perhaps) properties

    Moved Solved
    8
    0 Votes
    8 Posts
    917 Views
    S
    @J-Hilk said in accessing "child" (perhaps) properties: to address specific items(Components) by their index why do i have to use stackview at all? basicaly i wish to get the property via alias from the Item "parentObject", at the end this does not have to be bound to StackView, or does it? what you are saying is exactly my problem: @J-Hilk said in accessing "child" (perhaps) properties: No, components are not instances, you can push the InitialItem 200 times on the stack view, how would you differentiate between them? so if im pushing back and forward on each view, isnt it at the end the same view (not cloned like you mentione) just at the very top of all other views? or by each stacview.push() im cloning the view into new one and placing it atop? EDIT: i have tried to place onsole.log(currentItem) inside StackView{} to see how it will be changing, then i was clicking back and forth between two views and this is what i get: qml: InitialScreen_QMLTYPE_1(0x768e90) qml: ChoiseOffline_QMLTYPE_3(0xcbdd090) qml: InitialScreen_QMLTYPE_1(0xcd16340) qml: ChoiseOffline_QMLTYPE_3(0xce102a0) qml: InitialScreen_QMLTYPE_1(0xce6b230) qml: ChoiseOffline_QMLTYPE_3(0xce6b3b0) qml: InitialScreen_QMLTYPE_1(0xce9af60) so its realy generating new index each time i push(). so is it posible somehow search the newest view by its name? So i wish to search InitialScreen newest index of StackView... possible somehow?
  • dynamic width of widgets with splitter

    Unsolved
    2
    0 Votes
    2 Posts
    237 Views
    jsulmJ
    @DaJose https://doc.qt.io/qt-5/qsplitter.html
  • ListView issue when updated (current index set to 0)

    Unsolved
    8
    0 Votes
    8 Posts
    2k Views
    M
    Thanks for this precisions. i will have a look on the different options and let you know the more convenient way i will use
  • QML emulator crashes line 1

    Unsolved
    1
    0 Votes
    1 Posts
    149 Views
    No one has replied
  • This topic is deleted!

    Unsolved
    1
    0 Votes
    1 Posts
    14 Views
    No one has replied