Qt 4: Move window without title bar

Try this to move the window manually: void PopupWindow::mousePressEvent(QMouseEvent *event){ mpos = event->pos(); } void PopupWindow::mouseMoveEvent(QMouseEvent *event){ if (event->buttons() & Qt::LeftButton) { QPoint diff = event->pos() – mpos; QPoint newpos = this->pos() + diff; this->move(newpos); } } And declare QPoint mpos somewhere.

Distinguish between single and double click events in Qt

It’s a good UI design to make sure your single-clicks and double-clicks are conceptually related: Single-Click: select icon Double-Click: select icon and open it Single-Click: select color Double-Click: select color and open palette editor Notice how in these examples the single-click action is actually a subset of the double-click. This means you can go ahead … Read more

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

Make QWidget transparent

My best guess to show an overlay widget, is convert the widget to a window, resize it to it’s contents and move them to the desired position manually. MainWindow Example, showing the overlay widget in the center of the video widget: Mwindow::Mwindow() { widget = new Widget(this); } void Mwindow::widgetSizeMove() { if (widget->width() <= videoWidget->width() … 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

How to insert BLOB and CLOB files in MySQL?

Two ways: 1 – Use a LOAD_FILE function – INSERT INTO table1 VALUES(1, LOAD_FILE(‘data.png’)); 2 – Insert file as hex string, e.g. – INSERT INTO table1 VALUES (1, x’89504E470D0A1A0A0000000D494844520000001000000010080200000090916836000000017352474200AECE1CE90000000467414D410000B18F0BFC6105000000097048597300000EC300000EC301C76FA8640000001E49444154384F6350DAE843126220493550F1A80662426C349406472801006AC91F1040F796BD0000000049454E44AE426082′);