Different delegates for QML ListView

I’ve had the same problem, the Qt documentation is providing a pretty good answer: http://doc.qt.io/qt-5/qml-qtquick-loader.html#using-a-loader-within-a-view-delegate The easiest solution is an inline Component with a Loader to set a source file: ListView { id: contactsView anchors.left: parent.left anchors.top: parent.top width: parent.width height: parent.height orientation: Qt.Vertical spacing: 10 model: contactsModel delegate: Component { Loader { source: switch(position) … Read more

How to create a round mouse area in QML

Stealing code from PieMenu, here’s RoundMouseArea.qml: import QtQuick 2.0 Item { id: roundMouseArea property alias mouseX: mouseArea.mouseX property alias mouseY: mouseArea.mouseY property bool containsMouse: { var x1 = width / 2; var y1 = height / 2; var x2 = mouseX; var y2 = mouseY; var distanceFromCenter = Math.pow(x1 – x2, 2) + Math.pow(y1 – … Read more

How to create scrollbar in QtQuick 2.0?

ScrollBar/ScrollIndicator is easy to do, and the code would be identical in QQ1 or QQ2 (except the import) : ///////// ScrollBar.qml ////////////// import QtQuick 2.0; Item { id: scrollbar; width: (handleSize + 2 * (backScrollbar.border.width +1)); visible: (flickable.visibleArea.heightRatio < 1.0); anchors { top: flickable.top; right: flickable.right; bottom: flickable.bottom; margins: 1; } property Flickable flickable : … Read more

Deploy Qt5 QML application

If you use MinGW, then try to copy all folders from folders qml and plugins to directory with your program. Also copy libraries: icudt52.dll, icuin52.dll, icuuc52.dll, libgcc_s_dw2-1.dll, libstdc++-6.dll, libwinpthread-1.dll, Qt5Core.dll, Qt5Gui.dll, Qt5Network.dll, Qt5Qml.dll, Qt5Quick.dll, Qt5Svg.dll, Qt5Widgets.dll from bin Eventually the directory will look like this: Enginio imageformats platforms Qt QtGraphicalEffects QtPositioning QtQml QtQuick QtQuick.2 QtSensors … Read more

QML garbage collection deletes objects still in use

I’ve encountered this problem on several occasions, with objects created dynamically, regardless of whether they were created in QML or C++ Objects are only considered for garbage collection if they have JavaScriptOwnership set, which is the case if they are Directly created by JavaScript/QML Ownership is explicitly set to JavaScriptOwnership The object is returned from … Read more

QML and C++ image interoperability

It was possible to do in QtQuick1 but that functionality was removed in QtQuick2. The solution I’ve come up with allows to have the same image in QML and C++ by implementing a QQuickImageProvider that basically works with QPixmap * which is converted to string and then back to a pointer type(it does sound a … Read more