跳到內容

QML and Qt Quick

Looking for The Bling Thing(tm)? Post here!
20.1k 主題 77.6k 貼文
  • [Solved] How do I localize a Qt qmldir plugin?

    localization plugin
    3
    0 評價
    3 貼文
    3k 瀏覽
    I
    I just replied to you in stackoverflow, your solution is right, I copied my answer too: I created a Translator class to organize and load translations, I have a QVariantMap that holds language name and file name, then when I create my Translator I have to provide the source directory since that is a requirement to load translations, my class also takes care of storing in QSettings last language used. Now, to answer your question, you can always translate the exact same way as if it was a regular application, on your project file you will have to add something like this: 1 - List all your possible translations TRANSLATIONS = \ translation_sp.ts \ translation_fr.ts 2 - Run lupdate to generate the actual translation files lupdate project.pro 3 - Run lrelease Translate with linguist and create the actual translations, this will generate translation_sp.qm and translation_fr.qm 4 - Deploy translations with your plugin Once you have the qm files deploy them with your plugin, ideally you could standardize the naming, maybe always using plugin_XX.qm 5 - Load plugin translation in application To do this you will have to know the path to the translation file and the filename, so if your plugin is installed in the Qt default directories and you standardized the translation filenames this should be simple qTranslator.load("plugin_XX.qm", "PATH_TO_TRANSLATION_FILE") app->installTranslator(qtTranslator); I simplified this in my class, here is the source code if you want to take a look https://raw.githubusercontent.com/Iktwo/inventory/master/src/translator.cpp https://raw.githubusercontent.com/Iktwo/inventory/master/src/translator.h And here's how you use it: Translator translator(app.data(), "PATH_TO_TRANSLATION"); translator.addTranslation("SP", "plugin_XX.qm"); engine.rootContext()->setContextProperty("translator", &translator); You can install multiple translators, so it will work for your application and your plugins, when I wrote my class I was not expecting different sources but you can modify so every time you add a translation it will take a 2 letter code for the language, the filename and the path to it. Hope this helps!
  • Invisible buttons are still functioning

    qtqml qtquick differentviews states visibility
    13
    0 評價
    13 貼文
    10k 瀏覽
    p3c0P
    @vishnu I have a right-arrow button on my footer where i am pushing a qml file upon clicking. when it is loaded how to disable this button on the footer? enabled = false on click How can make a check before pushing If that is alread in the stack i don't the push it? 2 ways. var myItem = stackView.push( { item: Qt.resolvedUrl("DetailedView.qml"), destroyOnPop:false } ); //check myItem and store it somewhere if(myItem) { } var myItem = stackView.push( { item: Qt.resolvedUrl("DetailedView.qml"), destroyOnPop:false } ); var comp=stackView.get(myItem.Stack.index); //need the item to get its index and not just Stack.index
  • Get camera size[SOLVED]

    2
    0 評價
    2 貼文
    498 瀏覽
    Z
    Find sourceRect property in VideoOutput
  • How to create a "cut" shadow behind a rectangle?

    rectangularglow shadow
    2
    0 評價
    2 貼文
    1k 瀏覽
    X
    Will BorderImage work?
  • QML WebView not using username and password parts of https_proxy?

    1
    0 評價
    1 貼文
    1k 瀏覽
    尚無回覆
  • Scaling QML Item at arbitrary point and dragging the Scaled item within boundaries.

    1
    0 評價
    1 貼文
    414 瀏覽
    尚無回覆
  • Assigning or changing int property using enum inside QML

    c++ qml enum
    2
    0 評價
    2 貼文
    1k 瀏覽
    S
    Received answer on Stack Overflow. Note: The names of enum values must begin with a capital letter in order to be accessible from QML.
  • How to get visible delegates in a GridView

    gridview listvi
    1
    0 評價
    1 貼文
    493 瀏覽
    尚無回覆
  • [SOLVED] Qt Location QML : How to enable MapGestureArea ?

    qt location qml mapgesturearea
    3
    0 評價
    3 貼文
    2k 瀏覽
    S
    I misunderstood meaning of flick gesture so I missed that it was a reported bug although I did a search(for mapgesture). https://bugreports.qt.io/browse/QTBUG-46388 It is fixed in 5.6 but not 5.5. However there is a simple workaround. You have to add a MouseArea to the Map element as shown below : Map { id : map plugin: myPlugin anchors.fill: parent focus: true zoomLevel: 9 gesture.activeGestures: MapGestureArea.PanGesture | MapGestureArea.FlickGesture | MapGestureArea.ZoomGesture gesture.flickDeceleration: 3000 gesture.enabled: true //XXXXXXX Added MouseArea { anchors.fill: parent } //XXXXXXX } Thanks to Alexander for pointing me this.
  • Ministro + Qt 5.5

    ministro 5.5
    5
    0 評價
    5 貼文
    2k 瀏覽
    SGaistS
    Hi, @privet it might take a bit of patience, july is generally a month of holidays
  • How to do QML to C++ Property Binding

    5
    0 評價
    5 貼文
    1k 瀏覽
    Propakistanpk.comP
    @RahulY Thanks ! Good Information
  • 0 評價
    2 貼文
    2k 瀏覽
    p3c0P
    @dante I doubt that it will work readily with QML. Javascript support in QML is very restricted as compared to that of Web-Browsers. It lacks of certain objects which are mostly used in these web-browsers supported Javascripts. You can find more info here: http://doc.qt.io/qt-5/qtqml-javascript-hostenvironment.html http://doc.qt.io/qt-5/qtqml-javascript-expressions.html http://doc.qt.io/qt-5/qtqml-javascript-hostenvironment.html#javascript-environment-restrictions You will need to create you own port of it without those restrictions. For eg. here is a blog post for porting-three-js-code-to-canvas3d. Something similar will be needed for the rest too.
  • [SOLVED] Again... "Unable to handle unregistered datatype"

    4
    0 評價
    4 貼文
    3k 瀏覽
    p3c0P
    @topse That's because debug process takes some time and by then the registration is done while it is still busy processing the qml.
  • 0 評價
    1 貼文
    528 瀏覽
    尚無回覆
  • [Solved] Nested QtQuick delegates based on C++ model

    qml qtquick c++ delegates nested
    2
    0 評價
    2 貼文
    2k 瀏覽
    P
    I eventually found a solution/workaround to the problem. I am posting it here if anybody ever needs it. The main issue it seems is wanting to filter the C++ model in QML/JavaScript. Getting elements out of the C++ model into QML seems to be possible as a returning a QVariantMap maps to a JS object in the QML engine. Using this returned object as a model proved not to work directly. This might work with further effort but due to time constraints this approach was abandoned. The new approach was to create a C++ model derived from QAbstractItemModel and reimplementing the necessary functions. This model is essentially a filtering proxy for Model_A and Model_B. The filtering is implemented in QAbstractItemModel::getData() and the elements are exposed through a reimplementation of QAbstractItemModel::roleNames(). For this filtering proxy to change state when the underlying data changes the dataChanged() signals of the underlying models was connected to a method in the proxy model computing the correct index invoking emit dataChanged(index). The QML delegate reuse was then implemented as follows: Rectangle { // some rendering of Model_A Repeater { delegate: Delegate_B{} model: Item{ property var propertyDelegateB: model.propertyDelegateB // mulitple properties possible } } } This worked for my use case as I needed only one element in the model. For multiple elements this approach might not be ideal.
  • QML Button with irregular shapes

    3
    0 評價
    3 貼文
    2k 瀏覽
    PrezesP
    @p3c0 Great idea. Thank you very much !
  • [SOLVED]Qt Creator determined existing property as "non-existent property"

    button
    4
    0 評價
    4 貼文
    1k 瀏覽
    SGaistS
    Glad you found out and thanks for sharing the solution. Since you have it working now, please update the thread title prepending [solved] so other forum users may know a solution has been found :)
  • Quick and Raspberry Pi. Speed problem.

    1
    0 評價
    1 貼文
    402 瀏覽
    尚無回覆
  • 0 評價
    2 貼文
    4k 瀏覽
    B
    Well I found a solution. I post here so maybe it helps somebody. You need to declare a global property which stores the height. For example : reViewHeight Put the ListView inside a transparent Rectangle: rcView, and put the rectangle inside the ScrollView Add: Component.onCompleted: { reViewHeight = reViewHeight + height} in your delegate definition In the ListView add: onCountChanged: { rcView.height = reViewHeight } Done !
  • How to use FolderListModel?

    1
    0 評價
    1 貼文
    476 瀏覽
    尚無回覆