QTreeWidgetItem::setForeground no longer works with latest KF5

Tomas Mecir mecirt at gmail.com
Tue Jan 3 18:58:42 GMT 2023


You're not calling MOC. If using cmake:
include(KDECMakeSettings)
should do the trick. You'll need to also
#include "test.moc"
at the end of that cpp file.

The entire CMakeLists.txt that works for me is:

project(test)
cmake_minimum_required(VERSION 2.8.12)
find_package(ECM 0.0.10 REQUIRED CONFIG)
set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR} ${ECM_MODULE_PATH})
include(KDEInstallDirs)
include(KDECMakeSettings)
find_package(Qt5 REQUIRED COMPONENTS Core Gui Widgets)
find_package(KF5 REQUIRED COMPONENTS XmlGui I18n )
add_executable(test test.cpp)
target_link_libraries(test KF5::XmlGui KF5::I18n)

The app doesn't seem to do anything when started, but I'll leave that
part to you to figure out.

Hopefully this helps!

Tomas





Ășt 3. 1. 2023 v 19:30 odesĂ­latel Robin Atwood <binro at mailbox.org> napsal:
>
> I have made a bare-bones version of my code and guess what: it won't link! I get messages:
>
> /usr/src/dev/kde4/qtwitest/src/main.cpp:17: undefined reference to `vtable for QtwiTest'
>
> This is usually caused by not supplying a constructor body, but I have done that. Can anyone see what is wrong?
>
> #include <QApplication>
> #include <QMainWindow>
> #include <QTreeWidget>
> #include <KXmlGuiWindow>
> #include <KLocalizedString>
> class QtwiTest : public KXmlGuiWindow
> {
> Q_OBJECT
> public:
> QtwiTest();
> virtual ~QtwiTest();
> };
> QtwiTest::QtwiTest()
> {
> }
> QtwiTest::~QtwiTest()
> {
> }
>
> int main(int argc, char **argv)
> {
> QApplication app(argc, argv);
> KLocalizedString::setApplicationDomain("qtwi");
> QtwiTest mv;
> QTreeWidget tw( &mv );
> QTreeWidgetItem twi( &tw );
> QBrush fb( Qt::red );
>
> mv.setCentralWidget( &tw );
> mv.setCaption( "QTreeWidget Test", false );
> twi.setText( 0, "Line 1");
> twi.setForeground( 0, fb );
> tw.show();
>
> return app.exec();
> }


More information about the kde-devel mailing list