Skip to content

QML and Qt Quick

Looking for The Bling Thing(tm)? Post here!
20.0k Topics 77.3k Posts
  • C++ QML Wrappers wise or not

    4
    0 Votes
    4 Posts
    2k Views
    J
    If you write a signal in your Network c++ class and emit it doesn't solve your problem? @ class Network : public QObject { public: Q_OBJECT public: Network(QObject *parent = 0); ~Network(); signals: void message(message); };@ so, in qml: @import myapi Network { id: myNetwork onMessage: {console.log(message)} }@
  • More boxes to move in the same line.

    7
    0 Votes
    7 Posts
    1k Views
    p3c0P
    well then if it is at the same time then I think that your earlier approach is correct. For that you can create a separate Component or a QML file which will contain the PathAnimation and the Box and then later call this Component/QML file as many times you need.
  • [SOLVED] Reference error: id is not defined

    3
    0 Votes
    3 Posts
    16k Views
    P
    Thank you very much! Now it works.
  • How to iterate for each element of collection

    2
    0 Votes
    2 Posts
    782 Views
    D
    Hi I would probably do something like @ GridView{ id: myGridView anchors.fill: myBoard model: boardModel cellHeight: myBoard.frameSize cellWidth: myBoard.frameSize property int which : -1 //new delegate: SingleTile{ id : theDelegate Connections{ //new target : myGridView onWhichChanged :{ theDelegate.setFlipped(myGridView.which); } } } } function flipFrames(which){ myGridView.which = which; } @ The idea (which I find useful with QML) is to use property bindings and let each element act individually. This is a bit different from c++ where we are used to looping over a collection and tell each element what to do.
  • Flickering FBO When Resizing Vertically

    1
    0 Votes
    1 Posts
    969 Views
    No one has replied
  • Rearranging Items contained in GridLayout?

    4
    0 Votes
    4 Posts
    1k Views
    p3c0P
    Ok. Take your time and Happy Coding! :)
  • Qt Quick designer: how to add or bind property alias?

    3
    0 Votes
    3 Posts
    1k Views
    W
    Thanks Thomas, then I can't use it in the community edition. :-(
  • How can I send a signal to an Item which is inside a Loader ?

    2
    0 Votes
    2 Posts
    1k Views
    p3c0P
    Hi, AFAIK, you can do it in following ways: Using "Connect()":http://doc.qt.io/qt-5/qtqml-syntax-signals.html#connecting-signals-to-methods-and-signals Using "Connections()":http://doc.qt.io/qt-5/qml-qtqml-connections.html An example : @ Item { id: item width: 100 height: 150 signal sendMessage(string msg) Loader { id: loader width: 100 height: 100 sourceComponent: comp Component.onCompleted: item.sendMessage.connect(loader.item.setText) //comment Component.onCompleted if using Connections and vice versa } // Connections { // target: item // onSendMessage: { // loader.item.setText(msg) // } // } Component { id: comp Rectangle { anchors.fill: parent color: "red" function setText(msg) { mytext.text = msg } Text { id: mytext anchors.centerIn: parent } } } Button { text: "Click Me" y: 110 onClicked: item.sendMessage("Hello Qt") } } @
  • Exposing C++ model property of type QList<QObject*> to QML

    20
    0 Votes
    20 Posts
    22k Views
    J
    I know this is an old thread, but I had a similar problem to that of the original poster (stas2) I was able to have the QML read the QList properties correctly after using the following syntax in the QML view: @ListView { model: appData.axes delegate: Text { text: model.modelData.name } }@
  • Changing button image loses pressed signal

    8
    0 Votes
    8 Posts
    6k Views
    JKSHJ
    First, it's helpful to understand the following: The QML language is designed by Qt engineers, specifically for Qt applications. However, the JavaScript language is designed by people that are completely unrelated to the Qt Project. JavaScript is far older than QML, and it is widely used outside of QML. JavaScript is an imperative language. QML is a hybrid language. It consists of imperative parts (which are JavaScript expressions) and declarative parts. In other words, QML contains JavaScript plus other things. If you don't know the difference between declarative and imperative programming, do some "extra reading":http://stackoverflow.com/questions/1784664/what-is-the-difference-between-declarative-and-imperative-programming Secondly, make sure you understand how a "JavaScript conditional operator":https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Conditional_Operator works. Ok, now to address your questions and observations. To specify a property and a signal handler in a QML component, you need the following format: @ <COMPONENT> { <PROPERTY>: <JAVASCRIPT_EXPRESSION> <SIGNAL_HANDLER>: <JAVASCRIPT_STATEMENT> } @ Examine the snippet above: The colon "assigns" JavaScript code to a QML component's attribute. Note that a property's JS code is used differently from a signal handler's JS code: The JAVASCRIPT_EXPRESSION associated with a PROPERTY is evaluated every time a variable in the JAVASCRIPT_EXPRESSION changes value. The JAVASCRIPT_STATEMENT associated with a SIGNAL_HANDLER is evaluated every time the corresponding signal is emitted. [quote author="Binary91" date="1419677212"]when I use this line outside of the js statement using the colon ":", the binding works perfectly: @{ image.source: mousearea.pressed ? "imgPressed.png" : "img.png" mousearea.onClicked: { } }@ [/quote] The QML attribute is image.source (a property) Your JavaScript expression is mousearea.pressed ? "imgPressed.png" : "img.png" [quote author="Binary91" date="1419677212"]I don't understand why the following line in a js statement is a static assignment and not a property binding: @Button { mousearea.onClicked: { image.source = mousearea.pressed ? "imgPressed.png" : "img.png" } }@ [/quote] The QML attribute is mousearea.onclicked (a signal handler) Your JavaScript statement is image.source = mousearea.pressed ? "imgPressed.png" : "img.png" Remember, this statement is evaluated whenever the clicked signal is emitted. ** Every time you release the mouse button, the QML engine checks the value of mousearea.pressed, and then chooses a URL, and then assigns that URL to image.source ** mousearea.pressed is always false when you release the mouse button, so the same URL is chosen every time this statement is evaluated. That's why it feels like nothing is happening. [quote author="Binary91" date="1419677212"]when I try to use the colon ":" in the js statement like this: @{ mousearea.onClicked: { image.source: mousearea.pressed ? "imgPressed.png" : "img.png" } }@ , then QtCreator throws an error and doesn't compile my code...[/quote] The QML attribute is mousearea.onclicked (a signal handler) You attempted to use image.source: mousearea.pressed ? "imgPressed.png" : "img.png" as the JavaScript statement. However, this is illegal JavaScript code. Remember, QML needs to follow the rules of JavaScript Is this understandable? If not, please let me know and I'll try to explain differently.
  • [SOLVED] QtQuick 2 offscreen rendering - no Camera issue

    1
    0 Votes
    1 Posts
    610 Views
    No one has replied
  • How can I create simple container directly usable in QML designer.

    2
    0 Votes
    2 Posts
    820 Views
    T
    Here you can find a small example how to integrate a custom qml plugin into the designer: https://qt.gitorious.org/qt-creator/qt-creator/source/394c9dd5507df610f7d60a56b7bf7e707a59142f:tests/manual/qml/testprojects/plugins This is a manual test case, that we use to test the integration of custom QML items. If you put the QML file next to the file you edit (no import needed) nothing is required to get a basic integration. To get something like a collapsable GroupBox working I would suggest to overload the default property using an lias property, like the GroupBox of the Qt Quick Controls does it. The state of of the GroupBox should be exposed as a boolean property.
  • How to find / use Qt Quick 2D Renderer in Qt 5.4?

    9
    0 Votes
    9 Posts
    3k Views
    SGaistS
    You're welcome ! Since you have everything now, please update the thread title prepending [solved] so other forum users may know a solution has been found :)
  • [Solved] Qt Quick QML Image Quality

    5
    0 Votes
    5 Posts
    2k Views
    M
    I've found a solution and it works very well. Seems like it's a depth issue. Add this before your view show object. @ // CORRECTION DEPTH QSurfaceFormat surfaceFormat; surfaceFormat.setAlphaBufferSize(8); v.setClearBeforeRendering(true); v.setColor(QColor(Qt::transparent)); v.setFlags(Qt::FramelessWindowHint); v.setFormat(surfaceFormat); // CORRECTION DEPTH END@
  • Is is safe to upgrade to Yosemite OS X regarding Qt Creator ?

    6
    0 Votes
    6 Posts
    2k Views
    T
    I still have a lot of work to do on on my project in Windows so I have only compiled the debug version in OSX. It works fine. The only issue so far is I need to adjust the application font size. Some of the words are cut off because the font is too large. I still have to learn more about creating a release version in OSX. I haven't found any articles about a successful static deployment in OSX so I think I'll have to bundle all of the needed DLLs.
  • [SOLVED] First steps with ListView

    12
    0 Votes
    12 Posts
    3k Views
    B
    [quote]verticalCenter / horizontalCenter will position it to the center provided size is specified. The problem is that you cant use top, bottom, and verticalCenter anchors at the same time OR left, right, and horizontalCenter anchors at the same time. AFAIK verticalCenter and horizontalCenter will be ignored in that case.[/quote] Well, that makes sense, because using anchor top & anchor bottom already does the effect of anchor top + verticalCenter I think... Ok, so everything is clear. Thank you really much! Cheers,
  • Set root index in PathView

    2
    0 Votes
    2 Posts
    774 Views
    A
    Answer to my question is "QML DelegateModel":http://doc.qt.io/qt-5/qml-qtqml-models-delegatemodel.html
  • Scrollbar for list view

    3
    0 Votes
    3 Posts
    2k Views
    D
    Put the ListView in a "ScrollView":http://doc.qt.io/qt-5/qml-qtquick-controls-scrollview.html
  • Cannot assign to non-existent property in another qml file

    5
    0 Votes
    5 Posts
    11k Views
    D
    You have probably already noticed that the id in marqueeText.qml should not start with an upper case letter as described "here":http://doc.qt.io/qt-5/qtqml-syntax-objectattributes.html#the-id-attribute I main.qml you do @ MarqueeText { id:scrolltext width: 800 height: 48 text: "Qt Quick Digital Signage Demo" } @ This allocates a new instance of the MarqueeText class/element and has nothing to do with the id you provided in the MarqueeText.qml file
  • I want add text from textedit to database

    2
    0 Votes
    2 Posts
    732 Views
    D
    Hi, I think what you are looking for is : " here":http://doc.qt.io/qt-5/qsqlquery.html#approaches-to-binding-values