Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
885f9ce
Adapt to qt5
haider8645 Mar 28, 2022
5352d73
Remove extra includes and add missing libs
haider8645 Mar 28, 2022
9b72047
Remove global include directories as they are not needed anymore
haider8645 Apr 25, 2022
f1d33b8
Merge pull request #2 from haider8645/qt5
planthaber May 19, 2022
6537d55
Use qt5-designer as package dependency
pierrewillenbrockdfki Jun 15, 2022
f61cfee
Merge pull request #3 from pierrewillenbrockdfki/feature/qt5
planthaber Jun 16, 2022
21e0c9a
fix: Remove .pc file someone errornously stuck into the repository
pierrewillenbrockdfki Sep 23, 2025
851df9e
chore: Change to #pragma once instead of include guard
pierrewillenbrockdfki Sep 23, 2025
957e407
chore: Only use includes needed, use forward declarations in headers
pierrewillenbrockdfki Sep 23, 2025
4b6e099
fix: remove opengl requirement
pierrewillenbrockdfki Sep 23, 2025
7045da7
fix: properly use QtDesigner Qt component
pierrewillenbrockdfki Sep 23, 2025
9b51875
chore: Only use includes needed, use forward declarations in headers
pierrewillenbrockdfki Sep 23, 2025
092829b
fix: MyWidget::getPose does not really make sense as a Qt slot
pierrewillenbrockdfki Sep 23, 2025
7152df3
Merge commit '9b51875eea5fe267e5bc617caeb6d63a4269a80b' into feature/…
pierrewillenbrockdfki Sep 23, 2025
c942968
chore: Only use includes needed, use forward declarations in headers
pierrewillenbrockdfki Sep 23, 2025
644470b
fix: remove opengl requirement
pierrewillenbrockdfki Sep 23, 2025
9b319b0
fix: Use UiPlugin Qt5 component instead of Designer component
pierrewillenbrockdfki Sep 23, 2025
e482ba9
feat: Prepare master branch to also host Qt5 build
pierrewillenbrockdfki Sep 23, 2025
ff5002d
feat: Move to using RockQt macros
pierrewillenbrockdfki Sep 23, 2025
b7c0984
feat: Move to using RockQt macros
pierrewillenbrockdfki Sep 23, 2025
8cb1c98
Merge branch 'master' into feature/qt4-qt5
pierrewillenbrockdfki Sep 23, 2025
a787237
Rename HDRS to INSTALLED_HDRS to clearly communicate why they are dec…
pierrewillenbrockdfki Sep 23, 2025
95928c9
Set SRCS to the relevant file names instead of searching for *.cc
pierrewillenbrockdfki Sep 23, 2025
a60e479
feat: Use namespaced targets in cmake, pkgconfig package in .pc
pierrewillenbrockdfki Sep 23, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# CMakeLists.txt has to be located in the project folder and cmake has to be
# executed from 'project/build' with 'cmake ../'.
cmake_minimum_required(VERSION 2.6)
cmake_minimum_required(VERSION 3.5)
project(MyWidget VERSION 0.1 DESCRIPTION "Widget tutorial")
find_package(Rock)
rock_init(MyWidget 0.1)
rock_init()
rock_feature(NOCURDIR)
rock_standard_layout()
7 changes: 4 additions & 3 deletions manifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
<logo>http://</logo>

<depend package="base/types" />
<depend package="qt4" />
<depend package="qt-designer" />
<depend package="qt4-opengl" />
<depend package="qt4" optional="1" />
<depend package="qt-designer" optional="1" />
<depend package="qt5" optional="1" />
<depend package="qt5-designer" optional="1" />
</package>
65 changes: 47 additions & 18 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,34 +1,63 @@
find_package(Qt4 REQUIRED QtCore QtGui QtOpengl QtDesigner)
include_directories(${QT_INCLUDE_DIR})
include_directories(${QT_QTCORE_INCLUDE_DIR})
include_directories(${QT_QTGUI_INCLUDE_DIR})
rock_find_qt4(OPTIONAL QtCore QtGui QtDesigner)
rock_find_qt5(OPTIONAL Core Gui Widgets UiPlugin)

include(RockQt)

set(CMAKE_INCLUDE_CURRENT_DIR ON)

SET(MOC_HDRS
MyWidget.h
MyWidgetPlugin.h
)

SET(HDRS
SET(INSTALLED_HDRS
MyWidget.h
)

FILE(GLOB SRCS
*.cc
)
SET(SRCS
MyWidget.cc
MyWidgetPlugin.cc
)
# Alternatively, FILE(GLOB) can find any matching file in the directory.
# For this reason, the mywidgetTest executable uses main.cpp instead of main.cc.
#FILE(GLOB SRCS
# *.cc
#)

SET(QtApp_RCCS resources.qrc)
QT4_ADD_RESOURCES(QtApp_RCC_SRCS ${QtApp_RCCS})
if(ROCK_QT4)
QT4_ADD_RESOURCES(QtApp_RCC_SRCS_QT4 ${QtApp_RCCS})
endif()
if(ROCK_QT5)
QT5_ADD_RESOURCES(QtApp_RCC_SRCS_QT5 ${QtApp_RCCS})
endif()

rock_vizkit_widget(MyWidget
SOURCES ${SRCS} ${QtApp_RCC_SRCS}
HEADERS ${HDRS}
rock_qt_vizkit_widget(
TARGETPREFIX MyWidget
QT4_SUFFIX ""
SOURCES ${SRCS}
SOURCES_QT4 ${QtApp_RCC_SRCS_QT4}
SOURCES_QT5 ${QtApp_RCC_SRCS_QT5}
HEADERS ${INSTALLED_HDRS}
MOC ${MOC_HDRS}
DEPS_PKGCONFIG base-types base-lib QtCore QtGui
DEPS_CMAKE
LIBS ${QT_QTCORE_LIBRARY} ${QT_QTGUI_LIBRARY} ${QT_QTOPENGL_LIBRARY} ${QT_QTDESIGNER_LIBRARY}
DEPS_PKGCONFIG base-types base-lib
# Using the cmake targets for target_link_libraries but the
# pkgconfig packages in the .pc file.
# equivalent pkgconfig based configuration:
# DEPS_PKGCONFIG_QT4 QtCore QtGui
# DEPS_PKGCONFIG_QT5 Qt5Core Qt5Gui Qt5Widgets
# above will also add the dependencies to the .pc file, so they
# are not needed in the .pc.in.
LIBS_QT4 Qt4::QtCore Qt4::QtGui
LIBS_QT5 Qt5::Core Qt5::Gui Qt5::Widgets
# for include directories. These do not need to be added to the .pc files,
# the INSTALLED_HDRS do not use them.
LIBS_QT4 Qt4::QtDesigner
LIBS_QT5 Qt5::UiPlugin
)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here LIBS_QT4 above is used twice, so it could either be one call or the above shloud be different to add these into the pc file

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The first instance of that is for the option of either using LIBS_QT4 with Qt targets and supplying the pkg-config yourselves or using DEPS_PKGCONFIG but not having cmake check if one tries to link different Qts into the same binary.

The second instance of LIBS_QT4 is correct here since one only needs the pkgconfig requires: for things that are exported in headers(so the users of the headers link anything extra needed from the libraries by the headers), but the plugin-header does not need to be exported. I don't see a use-case where one would directly use the plugin-object instead of going through the plugin system. This may change when i find out how to statically add plugins to binaries.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So they aren't combined in a single (LIBS_QT4 Qt4::QtCore Qt4::QtGui Qt4::QtDesigner) line for documentation reasons?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thats my idea here, yes.


rock_executable(mywidgetTest
main.cpp
DEPS MyWidget)
rock_qt_executable(
TARGETPREFIX mywidgetTest
QT4_SUFFIX ""
SOURCES main.cpp
DEPS_QT MyWidget)
12 changes: 12 additions & 0 deletions src/MyWidget-qt5.pc.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
prefix=@CMAKE_INSTALL_PREFIX@
exec_prefix=@CMAKE_INSTALL_PREFIX@
libdir=${prefix}/lib
includedir=${prefix}/include

Name: @TARGET_NAME@
Description: @PROJECT_DESCRIPTION@
Version: @PROJECT_VERSION@
Requires: @DEPS_PKGCONFIG@ Qt5Core Qt5Gui Qt5Widgets
Libs: -L${libdir} -l@TARGET_NAME@
Cflags: -I${includedir}

3 changes: 3 additions & 0 deletions src/MyWidget.cc
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
#include "MyWidget.h"
#include <QGroupBox>
#include <QFormLayout>
#include <QLabel>

MyWidget::MyWidget(QWidget *parent)
: QWidget(parent)
Expand Down
17 changes: 11 additions & 6 deletions src/MyWidget.h
Original file line number Diff line number Diff line change
@@ -1,19 +1,26 @@
#ifndef MYWIDGET_H
#define MYWIDGET_H
#pragma once

#include <QtGui>
#include <QWidget>

#include <base/samples/RigidBodyState.hpp>

QT_BEGIN_NAMESPACE

class QGroupBox;
class QFormLayout;
class QLabel;

QT_END_NAMESPACE

class MyWidget : public QWidget
{
Q_OBJECT
public:
MyWidget(QWidget *parent = 0);
virtual ~MyWidget();
base::samples::RigidBodyState getPose();

public slots:
base::samples::RigidBodyState getPose();
void setPose(const base::samples::RigidBodyState pose);

private:
Expand All @@ -31,5 +38,3 @@ public slots:
QLabel* l3;

};

#endif /* MYWIDGET_H */
12 changes: 0 additions & 12 deletions src/MyWidget.pc

This file was deleted.

2 changes: 1 addition & 1 deletion src/MyWidget.pc.in
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ includedir=${prefix}/include
Name: @TARGET_NAME@
Description: @PROJECT_DESCRIPTION@
Version: @PROJECT_VERSION@
Requires: @DEPS_PKGCONFIG@
Requires: @DEPS_PKGCONFIG@ QtCore QtGui
Libs: -L${libdir} -l@TARGET_NAME@
Cflags: -I${includedir}

2 changes: 2 additions & 0 deletions src/MyWidgetPlugin.cc
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
#include "MyWidgetPlugin.h"
#include "MyWidget.h"

#if QT_VERSION < 0x050000
Q_EXPORT_PLUGIN2(MyWidget, MyWidgetPlugin)
#endif

MyWidgetPlugin::MyWidgetPlugin(QObject *parent)
: QObject(parent)
Expand Down
13 changes: 7 additions & 6 deletions src/MyWidgetPlugin.h
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
#ifndef MYWIDGETPLUGIN_H
#define MYWIDGETPLUGIN_H
#pragma once

#include <QtGui>
#include <QtDesigner/QDesignerCustomWidgetInterface>
#include <QObject>
#include <QtPlugin> // for Q_PLUGIN_METADATA and Q_EXPORT_PLUGIN2
#include <QDesignerCustomWidgetInterface>

class MyWidgetPlugin : public QObject, public QDesignerCustomWidgetInterface
{
Q_OBJECT
#if QT_VERSION >= 0x050000
Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QDesignerCustomWidgetInterface")
#endif
Q_INTERFACES(QDesignerCustomWidgetInterface)

public:
Expand All @@ -28,5 +31,3 @@ class MyWidgetPlugin : public QObject, public QDesignerCustomWidgetInterface
private:
bool initialized;
};

#endif /* MYWIDGETPLUGIN_H */
2 changes: 1 addition & 1 deletion src/main.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include <QtGui/QApplication>
#include <QApplication>

#include "MyWidget.h"

Expand Down