Skip to content

QML and Qt Quick

Looking for The Bling Thing(tm)? Post here!
20.1k Topics 77.6k Posts
  • Connect SpinBox to Slider (Dynamic Qml) [SOLVED]

    2
    0 Votes
    2 Posts
    3k Views
    H
    Ok, solved. Here is the code: @ import QtQuick 2.3 import QtQuick.Controls 1.2 ApplicationWindow { id: appWindow visible: true width: 400 height: 300 color: Qt.rgba(0, 0, 0, 1) property var sliders: [] property var spinBoxes: [] function createControl(itemType, where) { return Qt.createQmlObject("import QtQuick.Controls 1.2; " + itemType + " {}", where, "ApplicationWindow") } function spinBoxChanged() { for (var spinBox in appWindow.spinBoxes) appWindow.sliders[spinBox].value = appWindow.spinBoxes[spinBox].value } function sliderChanged() { for (var sliders in appWindow.sliders) appWindow.spinBoxes[sliders].value = appWindow.sliders[sliders].value } Component.onCompleted: { // Create some controls. for (var i = 0; i < 10; i++) { var slider = createControl("Slider", grid) var spinBox = createControl("SpinBox", grid) // Connect the SpinBox to the Slider. appWindow.sliders.push(slider) appWindow.spinBoxes.push(spinBox) slider.onValueChanged.connect(appWindow.sliderChanged) spinBox.onValueChanged.connect(appWindow.spinBoxChanged) } } Grid { id: grid columns: 2 anchors.fill: parent } } @
  • Cannot add a Qt resources file to Qt Quick UI

    2
    0 Votes
    2 Posts
    610 Views
    p3c0P
    Hi, AFAIK you can't add any cpp or resource files in Qt Quick UI project since this kind of project is meant to run only qml and javascript files with qmlscene executable.
  • [solved] Qml 'PathLine' - Controlling Spread of Elements

    4
    0 Votes
    4 Posts
    1k Views
    p3c0P
    You're Welcome :) Please mark the post as solved by editing the post title and appending [solved]. Happy Coding...
  • Sending signal from Qt Quick ApplicationWindow to C++ class

    5
    0 Votes
    5 Posts
    3k Views
    SGaistS
    Hi and welcome to devnet, Do you mean like described "here":http://qt-project.org/doc/qt-5/qtqml-cppintegration-interactqmlfromcpp.html#connecting-to-qml-signals ?
  • Memory Allocation

    4
    0 Votes
    4 Posts
    2k Views
    S
    The QML is: @ import QtQuick 1.1; Rectangle { id: root width: 500; height: 500; color: "white"; Rectangle { id: smallRectangle; anchors.centerIn: parent; width: 50; height: 50; } Rectangle { id: outputTextBorder anchors.centerIn: outputText color: smallRectangle.color; } Text { id: outputText anchors { left: parent.left; top: parent.top; margins: 30 } onTextChanged: { outputTextBorder.width = outputText.paintedWidth + 10; outputTextBorder.height = outputText.paintedHeight + 3; } } Text { id: outputText2 anchors { right: parent.right; top: parent.top; margins: 30 } } Text { id: outputText3 anchors { right: parent.right; bottom: parent.bottom; margins: 30 } } Text { id: outputText4 anchors { left: parent.left; bottom: parent.bottom; margins: 30 } } Loader { id: loader anchors.verticalCenter: smallRectangle.verticalCenter; anchors.left: smallRectangle.right; width: 100; height: 100; sourceComponent: theSource } Component { id: theSource Rectangle { anchors.fill: parent border.width: 2 radius: 5 border.color: "blue" function setColor(c) { border.color = c; innerText2.color = innerText.color; innerText.color = c; } function setText(t) { innerText.text = t; } function setText2(t2) { innerText2.text = t2; } Text { id: innerText height: 30 anchors.centerIn: parent color: "black" } Text { id: innerText2 anchors.top: innerText.bottom; anchors.horizontalCenter: innerText.horizontalCenter; color: "black" } } } Connections { target: model onColorChanged: { smallRectangle.color = color; outputTextBorder.color = color; loader.item.setColor(color); gc(); } onTextChanged: { outputText4.text = outputText3.text; outputText3.text = outputText2.text; outputText2.text = outputText.text; outputText.text = text; loader.item.setText(text); loader.item.setText2(outputText3.text); gc(); } } } @ The QML is also quite messy. I was trying to figure out what components/actions in QML exacerbate the frequency in allocations. It seems that Loaders really make this thing increase in size. When I run the program alongside task manager, it starts out at 5K which is what I would expect once loaded. However memory keeps increasing until it reached about 30K (took about a minute to two minutes to plateau). This is what I think I'm seeing in our production application only we are never able to reach the plateau because we run out of memory. An interesting exercise was to see if I could keep the memory from climbing from 5K to 30K. The way I finally found of achieving this was to clear the QPixmapCache. With this clearing, the result was the memory size would increase from 5 to 7, then back to 5. It was exactly what we needed. I'm not convinced that clearing the QPixmapCache is going to make the difference. The reason is because with multiple declarative views, only so much would fit in the cache anyways before it would start deallocating pixmaps. I did find an interesting thread that does match what I'm seeing: "http://qt-project.org/forums/viewthread/14492":http://qt-project.org/forums/viewthread/14492 Thanks again for the help.
  • RSS and QML

    3
    0 Votes
    3 Posts
    2k Views
    shavS
    Hi, Did you try to get access to 'content:encode' like 'content' or 'encoded'? I've the same problem when use QXmlInputSource and QDom* in C++ code. When I receive parsed datas and try to use it I receive 'content' field not 'content:encode'. I don't is this bug or this is right. Try to use content field. The problem when you RSS has a to field like in this rss http://blog.qt.digia.com/feed/ : @ <rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:sy="http://purl.org/rss/1.0/modules/syndication/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" version="2.0"> <channel> <title>Qt Blog</title> <atom:link href="http://blog.qt.digia.com/feed/" rel="self" type="application/rss+xml"/> <link>http://blog.qt.digia.com</link> <description>For Developers by Developers</description> <lastBuildDate>Fri, 17 Oct 2014 09:21:55 +0000</lastBuildDate> <language>en-US</language> sy:updatePeriodhourly</sy:updatePeriod> sy:updateFrequency1</sy:updateFrequency> <generator>http://wordpress.org/?v=3.6.1</generator> <item> <title>Qt 5.4 Beta Available</title> <link> http://blog.qt.digia.com/blog/2014/10/17/qt-5-4-beta-available/?utm_source=rss&utm_medium=rss&utm_campaign=qt-5-4-beta-available </link> <comments> http://blog.qt.digia.com/blog/2014/10/17/qt-5-4-beta-available/#comments </comments> <pubDate>Fri, 17 Oct 2014 09:00:21 +0000</pubDate> dc:creatorTuukka Turunen</dc:creator> <category> <![CDATA[ Licensing ]]> </category> <category> <![CDATA[ Qt ]]> </category> <category> <![CDATA[ Releases ]]> </category> <guid isPermaLink="false">http://blog.qt.digia.com/?p=40509</guid> <description> </description> content:encoded...</content:encoded> wfw:commentRss //get like commentRss http://blog.qt.digia.com/blog/2014/10/17/qt-5-4-beta-available/feed/ </wfw:commentRss> slash:comments14</slash:comments> //get like comments </item> @
  • [SOLVED] Update Property in a Qml (JS usage)

    5
    0 Votes
    5 Posts
    1k Views
    D
    So please add [SOLVED] to your thread title!
  • Difference between Qt Quick Application and Qt Quick UI?

    1
    0 Votes
    1 Posts
    734 Views
    No one has replied
  • Error with QtMultimedia 5.0 -qrc_qml.0 Error1

    1
    0 Votes
    1 Posts
    547 Views
    No one has replied
  • QQuickRenderControl example not working on Desktop OSX

    4
    0 Votes
    4 Posts
    1k Views
    SGaistS
    You're welcome ! Don't forget to post here if you can find a solution :)
  • 0 Votes
    4 Posts
    2k Views
    D
    Two hints: 1)For maintenance purpose, dynamic creation of QML object can be done using a QML file:(instead of a string ) Example: @ myObj = Qt.createComponent("Obj.qml"); if (myObj.status === Component.Ready) finishToCreateObj(); else myObj.statusChanged.connect(finishToCreateObj); function finishToCreateObj() { if (myObj.status == Component.Ready) { myObj.createObject(objParent, {id: anIdEasytoDefined } ); } else { ...error... } }@ 2) Using this method you can specified an id easily (in the previously code I set "anIdEasytoDefined"
  • Timeline (like Facebook) with GridView

    2
    0 Votes
    2 Posts
    1k Views
    D
    I don't check you code but I will do this using a Flickable element. This flickable is composed of a Repeater using a model When the scrollbar of the flickbale is "near then end", you just add need element in the model.
  • Qt Quick Application hangs when launched from remote desktop

    2
    0 Votes
    2 Posts
    907 Views
    D
    OpenGL apps used GPU to work. On remote desktop the GPU is not available
  • QQuickView in fullscreen

    9
    0 Votes
    9 Posts
    4k Views
    GianlucaG
    In Qt 5.3 the QQuickView has a showFullScreen method that to what the name suggest without setting any special flag. Of course, you still need to resize your root object correctly or let the QQuickView resize it for you specifying SizeRootObjectToView It works on Windows and Mac.
  • Place multiple items in one Cell in a GridView

    10
    0 Votes
    10 Posts
    3k Views
    M
    Thanks dasRicardo! I extend my code with a javascript to set my elements dynamically. But how can I set my button and my text in my gridview in one cell instead of placing them in separate cells? This is what I want: I Button I I Text I I Text I I Text I I I Button I I Text I I Text I I Text I This is how it looks like at the moment: I Button I I Button I I Text I I Text I I Text I I Text I I Text I I Text I my main.cpp @ #include <QApplication> #include <QQmlApplicationEngine> #include <QtQml> #include <client.h> #include <timeline.h> #include <QQmlComponent> int main(int argc, char *argv[]) { QApplication app(argc, argv); QQmlApplicationEngine engine; TimelineModel model; model.addDevice(Timeline("content/image/devices/water_heater.png", "1,70 €", "0,80 kWh", "16:00 - 16:45", true)); model.addDevice(Timeline("content/image/devices/tv", "1,70 €", "0,80 kWh", "16:00 - 16:45", true)); model.addDevice(Timeline("content/image/devices/device_placeholder.png", "1,70 €", "0,80 kWh", "16:00 - 16:45", true)); model.addDevice(Timeline("12 August", false)); engine.rootContext()->setContextProperty("timelineModel", &model); engine.load(QUrl(QStringLiteral("qrc:///main.qml"))); return app.exec&#40;&#41;; } @ my timeline.qml: @ import QtQuick 2.2 import QtQuick.Dialogs 1.1 import QtQuick.Controls 1.1 import "componentCreation.js" as MyScript Rectangle { id: timelineRectangle anchors.fill: parent visible: true Loader { id: qmlloader // anchors.fill: parent z: 1 } Rectangle { id: rectangle1 x: parent.width/2 - 10; width: 20 height: parent.height; color: "#000000" clip: false anchors.horizontalCenter: parent.horizontalCenter anchors.bottom: parent.bottom anchors.top: parent.top } Component { id: timelineDelegate Item { width: grid.cellWidth; height: grid.cellHeight Column { id: timelineColumn anchors.fill: parent spacing: 20 Component.onCompleted: MyScript.createSpriteObjects(timelineColumn&#41;; } } } GridView { id: grid flickableDirection: Flickable.AutoFlickDirection anchors.fill: parent cellWidth: grid.width/3 cellHeight: grid.height/3 anchors.margins: 100 delegate: timelineDelegate model: timelineModel } } @ my componentCreation.js: @ var component; var sprite; function createSpriteObjects(timeParent) { component = Qt.createComponent("TimelineItems.qml"); if (component.status == Component.Ready) { sprite = component.createObject(timeParent); } if (sprite == null) { // Error Handling console.log("Error creating object"); console.log("component: " + component.error); } } @ my TimelineItems.qml @ Rectangle { Column { Button {text: "Button"; anchors.horizontalCenter: parent.horizontalCenter} Text {text: "euro" } Text {text: "kwh" } Text {text: "time" } } } @
  • Qml blend modes

    3
    0 Votes
    3 Posts
    2k Views
    N
    Im not really familiar with OpenGL, so i have no idea what kind of fragmentshader is required by this solution. Is it time for me to dig into more opgenGL / glsl, or is there some site that offers a lot of default shaders which i could use?
  • QQuickView.grab() issue

    1
    0 Votes
    1 Posts
    516 Views
    No one has replied
  • 0 Votes
    2 Posts
    793 Views
    I
    This may not be the best way but what you could try to do is create an OpenGL context using a fake, high version and then check what was actually created. In QOpenGLContext's docs: "If the OpenGL implementation on your system does not support the requested version of OpenGL context, then QOpenGLContext will try to create the closest matching version." Example: @QSurfaceFormat requestedFormat; requestedFormat.setVersion( 99, 99 ); QOpenGLContext* context = new QOpenGLContext; context->setFormat( requestedFormat ); context->create(); qDebug() << QString("Requested OpenGL version (%1.%2); Actual created version (%3.%4).").arg(requestedFormat.majorVersion()).arg(requestedFormat.minorVersion()).arg(context->format().majorVersion()).arg(context->format().minorVersion());@
  • Hint about transitions

    3
    0 Votes
    3 Posts
    938 Views
    _
    Because I didn't know it :-) It seems it fits perfectly for my needs, thanks.
  • Flickable velocity

    2
    0 Votes
    2 Posts
    749 Views
    E
    The velocity just defines how fast the GridView should flick. You cannot set to which position it should flick as far as I know.