Here is how you can check and see if Windows is locked in Qt/C++. This same function will also let you know if the user is switched to another. Note that this involves using some Win32 API functions.
Continue reading “How to Check if Windows is Locked in Qt/C++”How to Update Your Qt Application’s Taskbar Icon at Runtime
To update a Qt app’s taskbar icon you need to create a QIcon object and assign it using setWindowIcon of the QApplication. Here is very simple example:
qApp->setWindowIcon(QIcon("path-to-an-image-file"));
Notice that you are not required to provide an icon file (*.ico , *.icns etc.) for this function to work and you can use any (standard) image file type such as *.jpg or *.png etc. This function can be called anywhere in the program. You can use this same method along with a QTimer to ANIMATE TASKBAR ICON.
How to make a 32-bit and 16-bit integers using 16-bit and 8-bit integers
You can use the following functions to merge 2 words (16-bit) or 4 bytes (8-bit) into a 32-bit integer. There is also a function which makes a word (16-bit) using two bytes (8-bit). I am using the in my Qt/C++ projects whenever I need them but with a slight change you can use them on your non-Qt projects too.
Continue reading “How to make a 32-bit and 16-bit integers using 16-bit and 8-bit integers”How to Configure a Single Qt Project for Different Operating Systems
There are many cases in every cross-platform development framework that you want your source code to be built differently under different operating systems. For example you might want a method to to use platform specific functions in Windows, Linux and Mac OS X but you don’t want to have different projects for each one of them. If you are in a similar situation then you can use the following approach to have a single integrated project for all operating systems that you are developing for.
Continue reading “How to Configure a Single Qt Project for Different Operating Systems”How to Make a Frameless Qt Window
Frame in a window is the part of window that is crated and managed by the OS. It contains usually contains all borders and title bar of the window. To remove the frame of any window using Qt you need to use the following piece of code:
setWindowFlags(Qt::Window | Qt::FramelessWindowHint);
Note that this will also cause the title bar of the window to be removed which means there will be no “close”, “minimize” and “maximize” buttons. So, you can use this same piece of code to remove all buttons from the title bar.
How to Get the Topmost Window Title using Qt/C++ (in Linux)
Below I have described the method to get active (focused) windows title using Qt in Linux systems (Such as Ubuntu, CentOS etc.) Basically you use xdotool with two parameters mentioned below to get the title of current window which has the focus.
Continue reading “How to Get the Topmost Window Title using Qt/C++ (in Linux)”How to Get Current User Name in Qt/C++ (for Linux)
You can use the following function to get current user name is Linux. I have tested this on Ubuntu and CentOS flavors but it should also work with other flavors without any issues.
Continue reading “How to Get Current User Name in Qt/C++ (for Linux)”How to Get the Topmost Window Title using Qt/C++ (for Windows)
In this article I am going to describe how to get the title of the window which has the focus, or in other word is currently active. To be able to achieve this in Qt/C++ you need to use the operating system API functions, in this case Win32 API.
Continue reading “How to Get the Topmost Window Title using Qt/C++ (for Windows)”How to Make Your Window Stay on Top in Qt
You can use the following snippet to make your MainWindow or any other window always on top:
setWindowFlags(windowFlags() | Qt::WindowStaysOnTopHint);
Just insert it in your window’s constructor function.
How to Access Android Camera Using Qt/C++
In this article I am going to describe the required steps needed for accessing Android Camera (or Default Camera Interface) using Qt. Unfortunately OpenCV does not provide a reliable way of connecting to Camera in Android so you have go for a method like this if you intend to write an Android application which uses OpenCV and Qt together. I strongly recommend that you should first read this article (which describes how to access Android Gallery from Qt) and also this article (which shows how to mix Java and C++ code in Qt) and then return here because I will be assuming that you are familiar with those processes. So if you can already access Android Gallery using Qt then continue reading the steps described below.
Continue reading “How to Access Android Camera Using Qt/C++”