开发者

Libqxt under Qt Creator

I want to create a tiny app which needs global shortcuts. So, I have downloaded the current version of libqxt (0.5.1) and opened as a project in Qt Creator.

Libqxt compiles without problems in this way, so I thought that adding this in the tab Dependencies of my project it would get added automatically in the build, like Eclipse does with JAR libraries (I know that are different IDEs but it seems to be a common feature among them).

What happens? Qt Creator compiles qxt before my project, when needed, but when I want to include its headers Qt Creator keeps warning me that it cannot find them.

Probably I am missing the correct name of headers (I tried the headers showed in qxt documentation: http://doc.libqxt.or开发者_Python百科g/0.5.0/classQxtGlobalShortcut.html)

By the way, I looked the code for global shortcuts and I think I can rip it out and use it in my app as is and I am going to credit qxt team and open the code of my app.


from the documentation

Add the following lines to your .pro file:

 CONFIG  += qxt
 QXT     += core gui

Note: While building the Qxt on Linux do not forget to do a sudo make install otherwise this little piece of magic may fail to work.


Qt Creator doesn't know how to expose different libraries to your projects. It's developer's duty. Dependency ensures only that mentioned projects are already built before building your main project.

Your real concern was using Qxt without proper installation. Assuming that configure have been run and libqxt have been built (using Qt Creator or manually via qmake+make), my solution is adding following snippet (with obvious QXT_DIR customization) to .pro file:

QXT_DIR = $${IN_PWD}/../libqxt-0.5.1
LIBS += -L$${QXT_DIR}/deploy/libs
INCLUDEPATH += $${QXT_DIR}/deploy/include
for(module, QXT) {
 MODNAME = $$upper($$replace(module, "(.).*", "\1"))$$replace(module, "^.", "")
 INCLUDEPATH += $${QXT_DIR}/deploy/include/Qxt$${MODNAME}
 INCLUDEPATH += $${QXT_DIR}/src/$${module}
 win32:CONFIG(debug, debug|release):MODNAME = $$join(MODNAME,,,d)
 LIBS += -lQxt$${MODNAME}
}

Unfortunately I'm not sure whether it works in complex projects.

By default Qxt is built in release mode, but Qt Creator uses debug mode and it leads to broken binaries of projects depending on Qxt under Windows. You have to switch your project to release mode or build Qxt in debug mode (run configure -debug and rebuild Qxt).

Last thing: In Windows you won't be able to run your project from Qt Creator even if you successfully build it. You must copy needed Qwt*.dll files (use the d-suffix versions if you're in debug mode) from libqxt-0.5.1/deploy/libs to your_project/(release|debug) directory .

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜