Creating a Visual Studio Console Application That Uses Qt Graphics

Using Qt graphics within a Visual-Studio console application is a non-standard use of the Qt software. The Qt tool qmake doesn't support the creation of console applications, so to use Qt graphics in a console application requires that you create your console application using Visual-Studio and then link to the required Qt graphics libraries. The essential steps are

  1. If you didn't keep the library you created in Assignment 5 (b), create a QtConsoleGraphics library using the qmake tools followed by nmake. Details

  2. Create a standard Win32 console project and add your project files and set the required paths and library information as needed.

  3. The additional program settings that are required to use Qt console graphics in a console project consists of



    Screenshot of sample Assign6 entries for Linker/General/Additional Library Directories
    Screenshot of sample Assign6 entries for additional linker input dependencies

  4. When your program is run from the IDE a console should appear allowing console input and output. If a graphics window is called (e.g. the frame() method of the graphics driver is invoked) then the graphics window may appear behind other windows. You can bring it to the front by selecting the icon for it from your toolbar or by cycling through your open windows using an Alt-Tab combination.


  5. For Linux/Unix users. To create a console Qt application one follows essentially the same process as for Visual Studio users. First,build the QtConsoleGraphics library (using make instead of nmake). Then create a standard console application, as in previous assignments, but with the additional specification of the include paths, library locations, and library names for the QtConsoleGraphics library and Qt software library.

Details on building a QtConsoleGraphics support library: Download the QtConsoleGraphics repository from https://www.math.ucla.edu/~anderson/157support/. Open up a Visual Studio Command Prompt window, and then cd to the QtConsoleGraphics directory and execute the commands

  1. qmake -project -t lib "CONFIG += staticlib"
  2. qmake
  3. nmake

    The result of this process should be a file QtConsoleGraphics.lib in the debug subdirectory of QtConsoleGraphics. This implicitly assumes that you downloaded the files to a directory QtConsoleGraphics.