0

I have a Qt application (Qt5) on linux which runs (and looks) perfectly fine. I have developed this using Qt Creator and so it gets built with the help of qmake by default.

But when I use cmake to build this project, the colors of all the widgets are disturbed (shown as below). Am I missing something anything in my CMakeLists file?

Here is my cmake file:

cmake_minimum_required(VERSION 3.0.2)

set (PROJECT_NAME QtTrialBuild)
project (${PROJECT_NAME})

find_package(Qt5Widgets REQUIRED)


set(CMAKE_INCLUDE_CURRENT_DIR ON)

include_directories(${Qt5Widgets_INCLUDES})
add_definitions(${Qt5Widgets_DEFINITIONS})

set(CMAKE_CXX_FLAGS "${Qt5Widgets_EXECUTABLE_COMPILE_FLAGS}")

set ( SOURCES
main.cpp
imageviewer.cpp
CRubberBand.cpp
CImageSelector.cpp
CSelectablePicture.cpp
CScale.cpp
)

set ( MOC_HEADERS
imageviewer.h
CRubberBand.h
CImageSelector.h
CSelectablePicture.h
CScale.h
)

set ( UIS
 imageviewer.ui
)

qt5_wrap_ui( UI_HEADERS ${UIS} )
qt5_wrap_cpp( MOC_SRCS ${MOC_HEADERS} )

add_executable(${PROJECT_NAME} ${SOURCES} ${MOC_SRCS} ${UI_HEADERS})

target_link_libraries( ${PROJECT_NAME} Qt5::Widgets)

When built with Qt Creator this is how the window looks (and that's how wanted it to be too)

But with Cmake

this is how it looked when built with cmake

The colors of the buttons, borders and pop-up windows are changed. Did I miss any parameters or did I forget to add something in the cmakelists?

eyllanesc
  • 235,170
  • 19
  • 170
  • 241
Krish
  • 45
  • 1
  • 8

1 Answers1

1

QT5_ADD_RESOURCES seems to be missing:

set(YourProject_RC
    YourProject.qrc
    YourProject2.qrc
)

QT5_ADD_RESOURCES(YourProject_RC_SRCS ${YourProject_RC})

add_executable(YourProject.UI
    ...
    ${YourProject_RC_SRCS}
    ...
)
Vertexwahn
  • 7,709
  • 6
  • 64
  • 90
  • I don't have any .qrc files in my project. I am pretty new to Qt, so not sure if I need one. But I am not using any external resources – Krish Jul 22 '17 at 23:38