How to make an application “Alway on Top” in C++ (For Qt and Win32)

I use the following method to make an application remain on top of other windows in Qt:

SetWindowPos
(
	(HWND)winId(),
	HWND_TOPMOST,
	window_top_pos,
	window_left_pos,
	window_width,
	window_height,
	SWP_SHOWWINDOW
);


Note that window_top_pos, window_left_pos, window_width and window_height are variables and you can replace them with your own.

Please be aware that this is a Win32 API function so it won’t work in Linux or MAC.

Don’t forget to add the include file to your code.

#include "windows.h"

And add the required library to your .PRO file.

LIBS += -luser32


How to use FTP in Qt (for Windows)

If you are in a situation that you want to upload a file to a FTP server or delete, rename, copy some files on a FTP server in your Qt programs there are no definite choices anywhere. At least that is the case with Qt 5.5. You usually have to use a platform dependent library. So here it is. I use this library when I need FTP access in Qt for Windows. It uses Windows API therefore you won’t be able to use this in Linux or MAC. Download from the link provided below (you may have to register at codeproject.com) and follow the steps to be able to use it in your Qt programs.

Continue reading “How to use FTP in Qt (for Windows)”

CATOX 2000

CATOX 2000 is a fully automatic metal sheet cutting system built by Ahmadi Industrial Group during 2000’s. It is able to get AutoCAD drawings as an input and cut the drawing from a metal sheet (iron, steel and any other metal type depending on the cutter section of the machine which can be Oxygen-Propane, Plasma or Laser) CATOX 2000 is widely used in heavy industries.

Continue reading “CATOX 2000”

How to use Windows API in Qt (A simple example)

Qt is a cross-platform framework that encapsulates API across many Operating Systems but one always faces situations in which he/she needs to access and use OS specific capabilities. Windows API is a massive collection of interfaces that allow a programmer to use and include Windows features in their programs.  Below is a simple example on how to use Windows API in Qt.

Let’s say we want to use GetSystemTime function in our Qt program. Searching Google for “GetSystemTime API” you’ll get the API Documentation from MSDN website. Parameters and return type values should be obvious:

Continue reading “How to use Windows API in Qt (A simple example)”

How to limit 32-bit applications to one instance in Visual C++ (with or without Qt)

I use the code from the following article to allow only a single instance of my programs (mostly written using Qt Framework) to run on Windows. Some programs (specially the ones which connect to a specific type of hardware or resource) need this limitation to avoid conflicts.

Please also note that this code is specific to Windows.

Continue reading “How to limit 32-bit applications to one instance in Visual C++ (with or without Qt)”