How to set application’s taskbar icon in Windows 7

I’ve found the answer, after some digging. In Windows 7, the taskbar is not for “Application Windows” per se, it’s for “Application User Models”. For example, if you have several different instances of your application running, and each instance has its own icon, then they will all be grouped under a single taskbar icon. Windows … Read more

Tcp packets using QTcpSocket

If a large amount of data is sent, the packet can arrive in separate parts. Alternatively, multiple messages can be received in one readyRead slot. It’s good practice to control this by setting the first byte(s) to the number of bytes that will be sent. Then, in readyRead, you read the first bytes and append … Read more

Building Qt 5 on Linux, for Windows

Here are the full instructions: Get it: git clone https://github.com/mxe/mxe.git Install build dependencies Build Qt 5 for Windows: cd mxe && make qtbase This will first build its dependencies and the cross-build tools; It should take less than an hour on a fast machine with decent internet access. Due to the new modular nature of … Read more

QCompleter Custom Completion Rules

Based on @j3frea suggestion, here is a working example (using PySide). It appears that the model needs to be set every time splitPath is called (setting the proxy once in setModel doesn’t work). combobox.setEditable(True) combobox.setInsertPolicy(QComboBox.NoInsert) class CustomQCompleter(QCompleter): def __init__(self, parent=None): super(CustomQCompleter, self).__init__(parent) self.local_completion_prefix = “” self.source_model = None def setModel(self, model): self.source_model = model super(CustomQCompleter, … Read more

QMake – how to copy a file to the output

You can use a qmake function for reusability: # Copies the given files to the destination directory defineTest(copyToDestdir) { files = $$1 for(FILE, files) { DDIR = $$DESTDIR # Replace slashes in paths with backslashes for Windows win32:FILE ~= s,/,\\,g win32:DDIR ~= s,/,\\,g QMAKE_POST_LINK += $$QMAKE_COPY $$quote($$FILE) $$quote($$DDIR) $$escape_expand(\\n\\t) } export(QMAKE_POST_LINK) } then use it … Read more

Draw Rectangular overlay on QWidget at click

This answer is in a series of my overlay-related answers: first, second, third. One way of doing it is: Have a semi-transparent overlay widget that is also transparent to mouse events. In the event filter, track the clicks and the resizing of the objects by adjusting the overlay’s geometry to match that of the target … Read more

How to specify different Debug/Release output directories in QMake .pro file

For my Qt project, I use this scheme in *.pro file: HEADERS += src/dialogs.h SOURCES += src/main.cpp \ src/dialogs.cpp Release:DESTDIR = release Release:OBJECTS_DIR = release/.obj Release:MOC_DIR = release/.moc Release:RCC_DIR = release/.rcc Release:UI_DIR = release/.ui Debug:DESTDIR = debug Debug:OBJECTS_DIR = debug/.obj Debug:MOC_DIR = debug/.moc Debug:RCC_DIR = debug/.rcc Debug:UI_DIR = debug/.ui It`s simple, but nice! 🙂

Qt Stylesheet for custom widget

I had a similar problem and it was solved using jecjackal’s comment. As sjwarner said, it would be much more noticeable in the form of an answer. So I’ll provide it. For the benefit of any future viewers. Again, it isn’t my answer! Appreciate jecjackal for it! As it is said in the Qt’s stylesheets … Read more