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

Running a program/script from QMake

It looks like QMAKE_POST_LINK works well for this sort of thing. This seems to get the job done. my_batch_file.bat runs when nmake runs (rather than when qmake runs) and I don’t need to do anything funny with placeholder targets or files. It’s quite likely that I don’t need all of the items listed in ‘CONFIG’. … Read more

How to tell QWebPage not to load specific type of resources?

The solution is to extend QNetworkAccessManager class and override it’s virtual method QNetworkAccessManager::createRequest In our implementation we check the path of the requested url and if it’s the one we don’t want to download we create and hand over an empty request instead of the real one. Below is a complete, working example. #include <QApplication> … Read more

Why do stylesheets not work when subclassing QWidget and using Q_OBJECT?

If you want custom QWidget subclasses to support stylesheets, you need to provide the following code: Qt Code: void myclass::paintEvent(QPaintEvent *pe) { QStyleOption o; o.initFrom(this); QPainter p(this); style()->drawPrimitive( QStyle::PE_Widget, &o, &p, this); }; Courtesy of wysota, as well as Qt help. When you don’t provide Q_OBJECT, your class has no Meta data, and hence is … Read more

How to install a missing Qt module?

Can I just download and install the missing module or do I have to reinstall Qt with the missing module selected? You don’t have to reinstall Qt. You can just use Qt Maintenance tool to to add components and to update or remove installed components. Launch Qt Maintenance Tool and choose Add or remove components. … Read more

Console input with Qt Creator

I found a solution. With Qt Creator 1.3.0 (on Mac OS X), here is what I had to do : Project->Run settings, check “Run in Terminal” (thanks Ropez) Qt Creator->Preferences : Environnement : General : Terminal : I had to put the whole path to XTerm. For my config, I had to put /usr/x11/bin/xterm -e. … Read more

How to convert qmake to cmake?

QMake: The required libraries. QT += core QT -= gui QT += network CMake: only the add is necessary. An exclude (QT -= gui) is not required. find_package(Qt5Core REQUIRED) find_package(Qt5Network REQUIRED) QMake: Additional Compiler flags: CONFIG += c++11 CMake: Extend the list of compiler flags as required. set(CMAKE_CXX_FLAGS “${CMAKE_CXX_FLAGS} -std=c++0x”) QMake: The source files SOURCES … Read more

paintEvent in QTableView derived class: Paint device returned engine == 0, type: 1

As QTableView is a subclass of QAbstractScrollArea you should open QPainter on its viewport: void CDerivedFromQTableView::paintEvent(QPaintEvent *event) { QTableView::paintEvent(event); // draw original content QPainter p(this->viewport()); p.drawRect(0, 0, 20, 20); } The docs say it: This event handler can be reimplemented in a subclass to receive paint events (passed in event), for the viewport() widget. Note: … Read more