[CMake] Simple Qt 3 Widget Example

Jacob Foshee jacobf at gmail.com
Mon Oct 8 12:16:04 EDT 2007


To whom it may concern:

Here is an example for building a Qt 3 widget as a lib (with CMake taking
care of all the moc and uic nonsense).  You will only need the .ui file
(which you can create in the Qt Designer) and the following CMakeLists.txt:

# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# #
PROJECT(MyWidget)

# Qt
FIND_PACKAGE(Qt3)
INCLUDE_DIRECTORIES(${QT_INCLUDE_DIR})
ADD_DEFINITIONS    (${QT_DEFINITIONS})

QT_WRAP_UI( ${PROJECT_NAME} WIDGET_H_LIST WIDGET_CPP_LIST
${PROJECT_NAME}.ui)
QT_WRAP_CPP(${PROJECT_NAME} WIDGET_CPP_LIST ${WIDGET_H_LIST})

ADD_LIBRARY(${PROJECT_NAME}
    ${WIDGET_H_LIST}
    ${WIDGET_CPP_LIST}
)

# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# #

Naturally, you only need to change "MyWidget" to the name of your widget
(case sensitive).

I do not yet use Qt 4, so I'm not sure if this would work just as well for
Qt 4.
Hope this is helpful,
Jacob
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://public.kitware.com/pipermail/cmake/attachments/20071008/388f8eec/attachment.html


More information about the CMake mailing list