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)”

Image Transformer (Fourier Transform App for Android)

UPDATE: This application is updated. Please read this post for more information.

My new application is a tool for for performing Fourier transformation on images. You can then apply masks to the Fourier representation of image and revert back (perform Inverse Fourier Transform) to see how the image gets affected.

For more information about Fourier Transform you can check out this link.

It is built using OpenCV and Qt and it is programmed completely in C++. I hope it would be useful for Image Processing and Machine Vision enthusiasts, researchers and students. It also contains some useful tips and tricks for programming Android applications using Qt and OpenCV such as:

  • How to open Android image gallery in Qt (Default interface)
  • How to capture images using default Android camera interface
  • How to crop images displayed on a QLabel
  • etc.



Source code (any part of it actually 🙂 ) is available upon request. Please send your requests using the Contact Me page.

Please consider supporting this application by giving a decent rating in Google Play.

For an example of Fourier transform using OpenCV please check out this link.

You can also see this link for more information about Fourier transform.

You can download this application from Google Play using the link below:

https://play.google.com/store/apps/details?id=com.amahta.ImageTransformer

trans_logo



How to connect to a COM library using Qt (An example of how to change Skype status using Qt and Skype4COM.DLL)

I wrote this program some time ago  to change my Skype status to Online and Away at different hours during the day. I decided I could share the source code because it is a good example on how to connect to a COM library using Qt.



Following should be noted about the source code provided in this post.

  • “skype4comlib” is produced using “dumpcpp” tool so you don’t need to create it yourself, and I also didn’t create it myself 🙂
    • Please refer to this link to get information on how to use dumpcpp.
  • Skype4COM library can be found here (usually)
    • C:Program Files (x86)Common FilesSkypeSkype4COM.DLL

Post a comment if there is anything confusing about the source code.

To test it just make sure Skype is running and just run the two Qt projects included in the source code.

Download



Qt Build Configure Options



I usually need to select a variety of options for building Qt depending on what I need and what I don’t need and strangely enough it is not easy to find the list of available options in the documentations so here it is.

Below is the list of all configure options for building Qt. It is taken from Qt 5.5 configure file which can be found under qtbase.

Continue reading “Qt Build Configure Options”

Add Administrator Level Privileges to Your Qt Program

Include the following in your project’s PRO file to have Administrator level privileges added to your program.

Following should be noted while using this:
1. This will only work if you are using a Microsoft Visual C++ compiler and Windows OS
2. Your OS might ask you for Administrator password or confirmation when you try to run your executable. This depends on how your OS is configured.
3. Qt Creator needs to be started as Administrator in order to run a program (for debugging) that has the following lines in its PRO file.

win32-msvc* {
    CONFIG += embed_manifest_exe
    QMAKE_LFLAGS_WINDOWS += $$quote( /MANIFESTUAC:\"level=\'requireAdministrator\' uiAccess=\'false\'\" )
}


How to build Qt 5.5 Static Libraries using any Microsoft Visual C++ Compiler

Following steps will help you with building Qt 5.5 Static Libraries with any MSVC Compiler. I have used MSVC2010 in this example but it should be the same for any compiler version from 2005 to 2015 (Visual Studio 2005 (8.0), VC++ 14.0)

Note that building Qt like this will remove all dependencies meaning there won’t be any need for MSVC dlls)

Continue reading “How to build Qt 5.5 Static Libraries using any Microsoft Visual C++ Compiler”

Add version information to your executables and libraries in Qt

Executable files have an embedded version information which can be found by checking their properties. It includes version number, comments, company info etc. As developer you sometimes need to leave a scratch on the EXE files you are providing to your customers in order to track what you have and what your customers have.

Continue reading “Add version information to your executables and libraries in Qt”

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)”