Skip to content

Commit

Permalink
Fix compatibility with Qt 6.8
Browse files Browse the repository at this point in the history
QPlatformInputContextFactory::requested will return QStringList, instead
of QString due to the new addition QT_IM_MODULES. Update the code to
support the concept of QT_IM_MODULES too.

Fix #64
  • Loading branch information
wengxt committed Oct 8, 2024
1 parent 331ce6d commit 0837a96
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions qt6/immodule-probing/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,17 @@ int main(int argc, char *argv[]) {
QGuiApplication app(argc, argv);
std::cout << "QT_QPA_PLATFORM=" << app.platformName().toStdString()
<< std::endl;
std::cout << "QT_IM_MODULE="
<< QPlatformInputContextFactory::requested().toStdString()
<< std::endl;
// This should work regardless QPlatformInputContextFactory::requested
// returns QString or QStringList
QStringList immodules{QPlatformInputContextFactory::requested()};
if (immodules.size() > 1) {
std::cout << "QT_IM_MODULES=\"" << immodules.join(";").toStdString()
<< "\"" << std::endl;
} else if (immodules.size() == 1) {
std::cout << "QT_IM_MODULE=" << immodules[0].toStdString() << std::endl;
} else {
std::cout << "QT_IM_MODULE=" << std::endl;
}
auto inputContext =
QGuiApplicationPrivate::platformIntegration()->inputContext();
std::cout << "IM_MODULE_CLASSNAME=";
Expand Down

1 comment on commit 0837a96

@microcai
Copy link

Choose a reason for hiding this comment

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

wowo, 可以啊。不用 ifdef 了。居然跑起来了。

Please sign in to comment.