Triple inheritance causes metaclass conflict… Sometimes

The error message indicates that you have two conflicting metaclasses somewhere in your hierarchy. You need to examine each of your classes and the QT classes to figure out where the conflict is. Here’s some simple example code that sets up the same situation: class MetaA(type): pass class MetaB(type): pass class A: __metaclass__ = MetaA … Read more

Setting application info in a Qt executable file on Windows

Here’s how I do it… add a file called resources.rc to your project with the contents: IDI_ICON1 ICON DISCARDABLE “res/app.ico” #include <windows.h> #include “version.h” VS_VERSION_INFO VERSIONINFO FILEVERSION VER_FILEVERSION PRODUCTVERSION VER_PRODUCTVERSION BEGIN BLOCK “StringFileInfo” BEGIN BLOCK “040904E4” BEGIN VALUE “CompanyName”, VER_COMPANYNAME_STR VALUE “FileDescription”, VER_FILEDESCRIPTION_STR VALUE “FileVersion”, VER_FILEVERSION_STR VALUE “InternalName”, VER_INTERNALNAME_STR VALUE “LegalCopyright”, VER_LEGALCOPYRIGHT_STR VALUE “LegalTrademarks1”, VER_LEGALTRADEMARKS1_STR … Read more

Serialization with Qt

QDataStream handles a variety of C++ and Qt data types. The complete list is available at http://doc.qt.io/qt-4.8/datastreamformat.html. We can also add support for our own custom types by overloading the << and >> operators. Here’s the definition of a custom data type that can be used with QDataStream: class Painting { public: Painting() { myYear … Read more

How to “Reveal in Finder” or “Show in Explorer” with Qt

Qt Creator (source) has this functionality, it’s trivial to copy it: void FileUtils::showInGraphicalShell(QWidget *parent, const QString &pathIn) { const QFileInfo fileInfo(pathIn); // Mac, Windows support folder or file. if (HostOsInfo::isWindowsHost()) { const FileName explorer = Environment::systemEnvironment().searchInPath(QLatin1String(“explorer.exe”)); if (explorer.isEmpty()) { QMessageBox::warning(parent, QApplication::translate(“Core::Internal”, “Launching Windows Explorer Failed”), QApplication::translate(“Core::Internal”, “Could not find explorer.exe in path to launch Windows … Read more

Console output in a Qt GUI app?

Windows does not really support dual mode applications. To see console output you need to create a console application CONFIG += console However, if you double click on the program to start the GUI mode version then you will get a console window appearing, which is probably not what you want. To prevent the console … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)