Skip to content

QML and Qt Quick

Looking for The Bling Thing(tm)? Post here!
20.0k Topics 77.4k Posts
  • MultiPointTouchArea don't work, with official example

    5
    0 Votes
    5 Posts
    2k Views
    S
    But, my question is, why qt developers decided to dont handle mouse events by MultiPointTouchArea ? I have resistive laptop with single-touch and it emulates mouse, so MultiPointTouchArea dont work. I think, it should work with mouse for compatibility reasons.
  • 0 Votes
    2 Posts
    3k Views
    G
    ohm... After some study. Maybe I should use the QAbstractItemModel ? Only QML thinks can't achieve my requirement. And, according to parse XML, I have found this "Simple DOM Model Example":http://qt-project.org/doc/qt-5/qtwidgets-itemviews-simpledommodel-example.html . I am not sure the exist class above link provide is what I need. I have kept studying the QAbstractItemModel. Can any one give me some suggestion or examples in QAbstractItemModel + QML to parse XML file? Or maybe it has another approach to achieve my requirement? Thank you!
  • Loading a large list model with a WorkerScript

    4
    0 Votes
    4 Posts
    1k Views
    U
    It also seems like you can't call clear() or append() on the ListModel from the QML when you have a WorkerScript. Even with judicious use of sync() the model and view still get out of sorts.
  • How to enable multi-touch in QML ?

    6
    0 Votes
    6 Posts
    3k Views
    S
    I have system, portable computer, with mouse and touch screen. And i want both to work simultanouesly. In addition, i want to same code without modifications work on tablet with linux (not android) with multitouch screen.
  • [SOLVED] How to call C++ class or function on QML

    8
    0 Votes
    8 Posts
    4k Views
    P
    Hi Kamb!z, Your Welcome to Qt's cross platform world !!! Thanks Prashant Moglaikar
  • QtQuick scenegraph Font rendering

    1
    0 Votes
    1 Posts
    693 Views
    No one has replied
  • How do I actually execute C++ code in Qt Quick?

    10
    0 Votes
    10 Posts
    3k Views
    X
    Ok I think in your case this is the simplest way you ca do it: create a QObject class with your functions and properties, what you want to use from QML, I have created a class claled MyStuff containing a single function "toPigLatin" for this example: @ class MyStuff : public QObject { Q_OBJECT public: explicit MyStuff(QObject *parent = 0) : QObject(parent) {} Q_INVOKABLE QString toPigLatin(const QString &s) { return s.mid(1) + s.left(1) + "ay"; } }; @ you can simply call that function from QML like any other QML function, see below. The function need to be a Qt slot or use the Qt macro Q_INVOKABLE to make it accessible from QML or other scripting languages. in your main.cpp create an Object of the MyStuff class and register the object as the QML context object, there are other ways like I said in an earlier post but in your case this might be the simplest way: @ QtQuick2ApplicationViewer viewer; // you should already have this in your main.cpp MyStuff myStuff; viewer.rootContext()->setContextObject(&myStuff); @ that is all, now you can use the function toPigLatin like any global function from anyway in your QML project, e.g.: @ Rectangle { width: 360 height: 360 MouseArea { anchors.fill: parent onClicked: console.log(toPigLatin("banana")) } } @ that is just the hello world QML code, only changed the onClicked slot to a console log, as you can see it calls the c++ function toPigLatin there. :) In the c++ side of the function you can do whatever you like, keep in mind the input and output parameters to QML will be converted by the QML engine, so you should use compatible types like QString and not std:.string, that won't work here (unless you provide a custom conversion from and to JavaScript). If you need to use a std:.string internally you can just convert the QString to a std::string with QString::toStdString(), but in your case I think QString is the better choice anyways. :)
  • How to get eval() to operate in the scope of QML element

    10
    0 Votes
    10 Posts
    3k Views
    Q
    I found the solution. Using Qt.include() allows for dynamic reloading of a javascript file at runtime, even if that javascript file has changed.
  • Modify phonon sound volume :

    1
    0 Votes
    1 Posts
    647 Views
    No one has replied
  • Including MessageDialog

    4
    0 Votes
    4 Posts
    2k Views
    X
    Hi, I just tested it myself, works like it should be with Qt 5.2.1, you don't need to add any special libraries or modules in the project file. My test code: @ import QtQuick 2.2 import QtQuick.Dialogs 1.1 Rectangle { width: 300 height: 300 Component.onCompleted: messageDialog.open() MessageDialog { id: messageDialog title: "May I have your attention please" text: "It's so cool that you are using Qt Quick." } } @ that is all.. be aware that QtQuick.Dialogs is a dynamic QML plugin, so if you deploy your app and don't run that code from Qt Creator you have to deploy the QtQuick.Dialogs plugin with your app, obviously. :)
  • MouseArea & Multitouch

    15
    0 Votes
    15 Posts
    15k Views
    S
    [quote author="feldifux" date="1337275306"]Thanks! So I'll implement my own item in C++ handling touch events, which has the same API as MouseArea so it is easy to use existing code with it. Because from a QML-user perspective, I would like to have an item where I dont have to care how many touchpoints there are, but only if there was a touch in the area I defined. So like a MultiPointTouchArea with a single touchPoint.[/quote] Could you share code with us or at least tell how to do this ?
  • QML formatted TextArea tab character

    1
    0 Votes
    1 Posts
    1k Views
    No one has replied
  • DPI-independent UI design with QML

    6
    0 Votes
    6 Posts
    11k Views
    V
    Xander84, thanks for the tip but it doesn't really work for me. I develop mobile app and use windows/macos on non-retina displays just to make development faster. Standard 96dpi are to small and devicePixelRation is equal to 1 on non-retina, so I multiply by 2 to make everything bigger :)
  • Item property changes defined in multiple places?

    3
    0 Votes
    3 Posts
    1k Views
    J
    I'm trying to add additional "PropertyChanges" to existing states. (When the page is shown I'd like to have additional animations triggered). I hoped I could put all the common functions into an inheritable object instead of repeating them on every page. I thought about trying to append a PropertyChange object to the existing "state object's changes property":http://qt-project.org/doc/qt-4.8/qml-state.html#changes-prop but it looks like it's read only. I might be able to trigger actions in the child objects using the when clause. Thanks for the help
  • 0 Votes
    3 Posts
    887 Views
    H
    It worked! Thanks. But my problem now is a seg fault with a few Elements in the ListModel. With only 8 elements, I get instant seg fault when I try to run the application. Im now trying to solve it. Thanks again.
  • Auto-indent on wordwrapped lines in TextEdit?

    1
    0 Votes
    1 Posts
    879 Views
    No one has replied
  • Qt Quick Getting Started Text Editor Error - Please Delete

    1
    0 Votes
    1 Posts
    631 Views
    No one has replied
  • [Solved] Deploying Qt Quick 2 application in OpenGL < 2 environment

    7
    0 Votes
    7 Posts
    2k Views
    T
    Turns out ANGLE works with Windows XP SP2, according to "this thread.":http://qt-project.org/forums/viewthread/32056 I couldn't manage to try out MESA though, couldn't build it.
  • Creating dynamic QML component with complicated data type failed

    7
    0 Votes
    7 Posts
    2k Views
    X
    Also there are other ways of creating dynamic objects, you can create an component like this: @ Component { id: blockComponent Block {} } @ in theory that should be the same as @ var blockComponent = Qt.createComponent( "Block.qml" ); @ only as an QML object and not a local variable. the advantage is you can simply define default values or anything in the Block object, but still create dynamic objects with the ID (you should not use a first capital letter for variable names and IDs): @ var block = blockComponent.createObject(parent); @
  • Qt 5.2 QML WebView height: contentHeight

    2
    0 Votes
    2 Posts
    1k Views
    Z
    @import QtQuick 2.0 import QtWebKit 3.0 Item{ width: 400 height: 300 Flickable { anchors.fill: parent contentWidth: parent.width contentHeight: webView.height + label.height Text { id: label text: "Hehe" } WebView { id: webView anchors.top: label.bottom url: "http://www.google.com" width: parent.width height: contentHeight } } }@