VolumeRendering

Qt Framework

Qt Main Window | | QGL Introduction

The previously drescribed Qt modules make up a basic Qt application that serves as framework for upcoming applications. It is also available from svn:

svn co svn://schorsch.efi.fh-nuernberg.de/qt-framework

It is also available in the WebSVN frontend:

To compile it we use CMake.

We assume that there is a main module main.cpp and one additional module that contains the main window class in mainwindow.cpp/.h. Then the CMake file needs to take care of the MOCification of those two application modules. CMake handles that automatically if told so:

# cmake build file

PROJECT(MyQtProject)

CMAKE_MINIMUM_REQUIRED(VERSION 2.8.11)

# application name
SET(APPNAME myqtapp)

# non-standard path to Qt4
SET(CMAKE_PREFIX_PATH ${CMAKE_PREFIX_PATH};
    /usr/local/Trolltech/Qt-4.7.4;
   )

# Qt4 dependency
SET(QT_USE_QTOPENGL TRUE)
FIND_PACKAGE(Qt4 COMPONENTS QtCore QtGui REQUIRED)
INCLUDE(${QT_USE_FILE})
ADD_DEFINITIONS(${QT_DEFINITIONS})

# OpenGL dependency
FIND_PACKAGE(OpenGL)

# header list
SET(LIB_HDRS
   mainwindow.h
   )

# module list
SET(LIB_SRCS
   mainwindow.cpp
   )

# moc
QT4_WRAP_CPP(MOC_OUTFILES ${LIB_HDRS})

# library
SET(LIB_NAME ${PROJECT_NAME})
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR})
ADD_LIBRARY(${LIB_NAME} ${LIB_SRCS} ${LIB_HDRS} ${MOC_OUTFILES})

# executable
ADD_EXECUTABLE(${APPNAME} MACOSX_BUNDLE main.cpp)
TARGET_LINK_LIBRARIES(${APPNAME}
   ${LIB_NAME}
   ${QT_LIBRARIES}
   ${OPENGL_LIBRARIES}
   )

# install target
INSTALL(
   TARGETS ${APPNAME}
   RUNTIME DESTINATION bin
   BUNDLE DESTINATION /Applications
   )

# install .desktop file for KDE4 (and Gnome)
IF (UNIX AND NOT APPLE)
   INSTALL(FILES ${APPNAME}.desktop DESTINATION /usr/share/applications)
ENDIF (UNIX AND NOT APPLE)

Once we compiled the Qt application with

cmake . && make

we install the application with

sudo make install

This creates an application bundle in /Applications on MacOS X or installs the application with a respective .desktop file for Gnome and KDE to be available through the start menu on Ubuntu or OpenSuse.

Qt Main Window | | QGL Introduction

Options: