<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Qt Creator &#x2F; Designer custom widget clock example desktop failing to build]]></title><description><![CDATA[<p dir="auto">I have built from the git sources both Qt6.7.1 and QtCreator 13.0.2 plus built the documentation so I could also get to all the examples.</p>
<p dir="auto">I have successfully built the dice example hence know everything compiles ok but am now struggling with the setup required for a custom widget to be used</p>
<p dir="auto">I may be approaching this wrong and so looking for some help on getting it working please.</p>
<p dir="auto">So far I have:</p>
<ol>
<li>Built the analog clock  'custom widget plugin' example in /myQt671/examples/designer/customwidgetplugin/ directory.</li>
<li>Configured cmake to install to my plugins directory so this /myQt671/plugins/designer/libcustomwidgetplugin.so</li>
<li>Started a new Creator project (Application, Qt Widgets Application) named cdgClockDesktop, opened the mainwindow.ui and dragged a clock instance onto it which is showing the clock face ticking away.</li>
<li>Tried to compile and build the solution which initially gave an error that the header file could not be found but fixed that by putting an absolute link to it in the customwidgetplugin.cpp include file section.</li>
</ol>
<p dir="auto">Now I am stuck as I am getting a linking error when trying to build  using the plugin saying that `AnalogClock::AnalogClock(QWidget*)' is an undefined reference.</p>
<p dir="auto">I'm assuming that is because I haven't got anything that is telling the linker to include the plugin library  where the actual clock functions exist.</p>
<p dir="auto">I'm using CMake and all the examples i have found are older using QMake so not helped I'm assuming I need something in the CMakeLists.txt to reference out to the <a href="http://libcustomwidgetplugin.so" target="_blank" rel="noopener noreferrer nofollow ugc">libcustomwidgetplugin.so</a> when linking but can't work it out or maybe this approach is wrong and there is a better way ?</p>
]]></description><link>https://forum.qt.io/topic/157115/qt-creator-designer-custom-widget-clock-example-desktop-failing-to-build</link><generator>RSS for Node</generator><lastBuildDate>Tue, 17 Nov 2026 19:20:43 GMT</lastBuildDate><atom:link href="https://forum.qt.io/topic/157115.rss" rel="self" type="application/rss+xml"/><pubDate>Fri, 07 Jun 2024 12:09:20 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Qt Creator &#x2F; Designer custom widget clock example desktop failing to build on Fri, 07 Jun 2024 17:01:13 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/cg-123">@<bdi>CG-123</bdi></a> So getting there if anyone else has this problem trying to use CMake.</p>
<p dir="auto">In my CMakeLists.txt I have found by using the find_library command and ensuring that the directory for the plugins is in my PATH that I can then use the CLOCK_WIDGET result in the target link library section.</p>
<pre><code>find_library(CLOCK_WIDGET customwidgetplugin)
</code></pre>
<p dir="auto">and</p>
<pre><code>target_link_libraries(cdgClockDesktop  PRIVATE Qt${QT_VERSION_MAJOR}::Widgets "${CLOCK_WIDGET}")
</code></pre>
]]></description><link>https://forum.qt.io/post/802094</link><guid isPermaLink="true">https://forum.qt.io/post/802094</guid><dc:creator><![CDATA[CG-123]]></dc:creator><pubDate>Fri, 07 Jun 2024 17:01:13 GMT</pubDate></item><item><title><![CDATA[Reply to Qt Creator &#x2F; Designer custom widget clock example desktop failing to build on Fri, 07 Jun 2024 13:30:49 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/pl45m4">@<bdi>Pl45m4</bdi></a> Yes I have followed the steps in the example html and the clock plugin itself is working great.</p>
<p dir="auto">My issue is how to build a proejct using it.</p>
<p dir="auto">To help try and prove where my issue is I have just created a project using qmake and in the qmake .pro file added the external library through the additional lines</p>
<pre><code>unix:!macx: LIBS += -L$$PWD/../../myQt671/plugins/designer/ -lcustomwidgetplugin

INCLUDEPATH += $$PWD/../../myQt671/plugins/designer
DEPENDPATH += $$PWD/../../myQt671/plugins/designer
</code></pre>
<p dir="auto">and that works perfectly so it is something in my CMake setup.</p>
<p dir="auto">My CMakeLists.txt file is:</p>
<pre><code>cmake_minimum_required(VERSION 3.5)

project(cdgClockDesktop VERSION 0.1 LANGUAGES CXX)

set(CMAKE_AUTOUIC ON)
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)

set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

find_package(QT NAMES Qt6 Qt5 REQUIRED COMPONENTS Widgets)
find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Widgets)

set(PROJECT_SOURCES
        main.cpp
        mainwindow.cpp
        mainwindow.h
        mainwindow.ui
)

qt_add_executable(cdgClockDesktop MANUAL_FINALIZATION ${PROJECT_SOURCES})

target_link_libraries(cdgClockDesktop  PRIVATE Qt${QT_VERSION_MAJOR}::Widgets )


# Qt for iOS sets MACOSX_BUNDLE_GUI_IDENTIFIER automatically since Qt 6.1.
# If you are developing for iOS or macOS you should consider setting an
# explicit, fixed bundle identifier manually though.
if(${QT_VERSION} VERSION_LESS 6.1.0)
  set(BUNDLE_ID_OPTION MACOSX_BUNDLE_GUI_IDENTIFIER com.example.cdgClockDesktop)
endif()
set_target_properties(cdgClockDesktop PROPERTIES
    ${BUNDLE_ID_OPTION}
    MACOSX_BUNDLE_BUNDLE_VERSION ${PROJECT_VERSION}
    MACOSX_BUNDLE_SHORT_VERSION_STRING ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}
    MACOSX_BUNDLE TRUE
    WIN32_EXECUTABLE TRUE
)

include(GNUInstallDirs)

install(TARGETS cdgClockDesktop
    BUNDLE DESTINATION .
    LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
    RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
)

if(QT_VERSION_MAJOR EQUAL 6)
    qt_finalize_executable(cdgClockDesktop)
endif()
</code></pre>
<p dir="auto">I don't know how to include the plugin directory and configure Cmake so it is succesfully linked to in the way QMake specifies it.</p>
]]></description><link>https://forum.qt.io/post/802084</link><guid isPermaLink="true">https://forum.qt.io/post/802084</guid><dc:creator><![CDATA[CG-123]]></dc:creator><pubDate>Fri, 07 Jun 2024 13:30:49 GMT</pubDate></item><item><title><![CDATA[Reply to Qt Creator &#x2F; Designer custom widget clock example desktop failing to build on Fri, 07 Jun 2024 12:55:59 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/cg-123">@<bdi>CG-123</bdi></a> said in <a href="/post/802078">Qt Creator / Designer custom widget clock example desktop failing to build</a>:</p>
<blockquote>
<p dir="auto">Tried to compile and build the solution which initially gave an error that the header file could not be found but fixed that by putting an absolute link to it in the customwidgetplugin.cpp include file section.</p>
</blockquote>
<p dir="auto">How does your CMake file look like?</p>
<p dir="auto">Are you following these steps here?</p>
<ul>
<li><a href="https://doc.qt.io/qt-6/qtdesigner-customwidgetplugin-example.html" target="_blank" rel="noopener noreferrer nofollow ugc">https://doc.qt.io/qt-6/qtdesigner-customwidgetplugin-example.html</a></li>
</ul>
]]></description><link>https://forum.qt.io/post/802081</link><guid isPermaLink="true">https://forum.qt.io/post/802081</guid><dc:creator><![CDATA[Pl45m4]]></dc:creator><pubDate>Fri, 07 Jun 2024 12:55:59 GMT</pubDate></item></channel></rss>