How to execute shell command after compile finished from .pro in QT?

I had a similar problem. I wanted a special tool (versioner) to run over the code every time the Makefile was executed. Here’s the solution: (to be read in the Qmake Manual, Configuring qmake’s Environment, Section: Customizing Makefile Output) Create you own Makefile target. Specify the command etc. = .buildfile mytarget.commands = touch $$ … Read more

Different delegates for QML ListView

I’ve had the same problem, the Qt documentation is providing a pretty good answer: The easiest solution is an inline Component with a Loader to set a source file: ListView { id: contactsView anchors.left: parent.left width: parent.width height: parent.height orientation: Qt.Vertical spacing: 10 model: contactsModel delegate: Component { Loader { source: switch(position) … Read more

How to drop a custom QStandardItem into a QListView

It looks like you want setItemPrototype. This provides an item factory for the model, so that it will implicitly use your custom class whenever necessary. All you need to do is reimplement clone() in your item class: class MyItem(QtGui.QStandardItem): ”’This is the item I’d like to drop into the view”’ def __init__(self, parent=None): super(MyItem, self).__init__(parent) … Read more

qfiledialog – Filtering Folders?

You can try setting a proxy model for your file dialog: QFileDialog::setProxyModel. In the proxy model class override the filterAcceptsRow method and return false for folders which you don’t want to be shown. Below is an example of how proxy model can look like; it’c c++, let me know if there are any problems converting … Read more

Dynamic instantiation of QML objects?

You could simply: import QtQuick 2.0 Rectangle { id: root height: 500 width: 500 property string sc: ‘import QtQuick 2.0; Rectangle {width: 20; height: 20; color: “red”; Component.onCompleted: {x = Math.random() * parent.width; y = Math.random() * parent.height;}}’ Component.onCompleted: { for (var i = 0; i < 10; ++i) Qt.createQmlObject(sc, root, ‘obj’ + i); } … Read more

How to build the Qt-SQL-driver-plugin ‘QSQLCIPHER’ for SQLite-DB with SQLCipher-extension using the Windows/MinGW-platform?

How to build the Qt-SQL-driver-plugin ‘QSQLCIPHER’ for SQLite-DB with SQLCipher-extension using the Windows/MinGW-platform: Qt 5.4.0 for Windows/MinGW Download Qt Install including the sources e.g to C:\Qt\Qt5.4.0 OpenSSL for Windows Download Win32 OpenSSL v1.0.2a Download Visual C++ 2008 Redistributable Install Visual C++ 2008 Redistributable by executing ‘vcredist_x86.exe’ Install OpenSSL v1.0.2a by executing ‘Win32OpenSSL-1_0_2.exe’ Target directory e.g. … Read more

PyQt5 and QtGui module not found

When first trying pyqt4 and pyqt5 and the pycharm IDE I had many problems with imports. (although the imports had no prob running from IDLE) Eventually after much stuffing around, uninstalling and reinstalling, (including dependencies) the imports sorted themselves out. Did you install pyqt5 using an installer from the pyqt website? You must. Qt designer … 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:; right: flickable.right; bottom: flickable.bottom; margins: 1; } property Flickable flickable : … Read more