creator找不到文件路径 qt_Qt Creator中找不到头(说:"没有这样的文件或目录")...

How can I tell Qt Creator 2.4.1 (based on Qt 4.7.4 32-bit) where to look by default for header files?

When I open a C file in Qt Creator and say

#include

it underlines the line and says

stdio.h: No such file or directory

I would like to tell it to look for headers in a directory of my choice; how do I do this?

Update

I guess I should also ask: Is this even possible? Or must I create an entire project every time I want to edit a standalone C++ file?

解决方案

I found myself often faced with this problem. I can reproduce it on my machine right now as well (Mac OS).

It looks like QtCreator needs to have a project to correctly handle GCC path analysis (on top of Qt frameworks pathes).

The process Qt uses to find the headers is that it launches GCC (or your compiler on Windows) with special arguments that make it output the pathes where the compiler finds its headers. BUT, to do that, it must have a project associated to your files, because it uses this project to determine what toolchain to use, thus where GCC is found.

So the answer is this: create a project, always, to use the syntax analyzis.

Note that it is quite important that when you create this project, you define which version of the Qt SDK and the toolchain you'll use, otherwise the syntax control-click won't work.

You might find some interesting ways of using a Qt Project file although not using the Qt SDK or using Creator to build your project. See an answer to a similar question here: http://stackoverflow.com/a/5817226/389405

Note that I personnally use this method, with a .pro file that simply lists all the subdirectories of my project, and with all keyboard shortcuts to build disabled, so that I only use Qt Creator as an editor. The syntax highlighting/linking is awesome and exceptionnally quick, far, far quicker than Eclipse!

To do that, simply issue qmake -pro in the directory of your project. It will create a [DIR].pro file that you can remove any time.

I filled a bug a year ago on an aspect of this syntax analyzis that was bothering me here: https://bugreports.qt-project.org/browse/QTCREATORBUG-4846 , the reason beiing that the compiler I use output its data in French instead of English. They fixed the code in 2.4 but it might be Unix-specific (see the comments of the issue for more information) so you'll probably want to test if this issue can be applied to your case.

If your issue continues even after creating a project for your edition, make sure to point it to the guys at qt-project.org !

Otherwise, the only solution I see is modifying the source code of QtCreator. You can find in their last post some information about how to contribute here: http://labs.qt.nokia.com/2012/03/15/qt-creator-2-5-beta/ (and try their new beta which supports C++ lambdas).

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值