The locator provides one of the easiest ways in Qt Creator to browse through projects, files, classes, methods, documentation and file systems. You can find the locator in the bottom left of the Qt Creator window.
To activate the locator, press Ctrl+K (Cmd+K on Mac OS X) or select Tools > Locate....
To edit the currently open project's main.cpp file using the locator:
- Activate the locator by pressing Ctrl+K.
- Enter main.cpp.
- Press Return.
The main.cpp file opens in the editor.
It is also possible to enter only a part of a search string. As you type, the locator shows the occurrences of that string regardless of where in the name of an component it appears.
To narrow down the search results, you can use the following wildcard characters:
- To match any number of any or no characters, enter *.
- To match a single instance of any character, enter ?.
Using the Locator Filters
The locator allows you to browse not only files, but any items defined by locator filters. By default, the locator contains filters which locate:
- Any open document
- Files anywhere on your file system
- Files belonging to your project, such as source, header resource, and .ui files
- Class and method definitions in your project or anywhere referenced from your project
- Help topics, including Qt documentation
- Specific line in the document displayed in your editor
To use a specific locator filter, type the assigned prefix followed by Space. The prefix is usually a single character.
For example, to locate symbols matching QDataStream:
- Activate the locator.
- Enter : QDataStream (: (colon) followed by a Space and the symbol name (QDataStream)).
The locator lists the results.
By default the following filters are enabled and you do not need to use their prefixes explicitly:
- Going to a line in the current file (l).
- Going to an open file (o).
- Going to a file in any open project (a).
Using the Default Locator Filters
The following locator filters are available by default:
|Function||Enter in locator||Example|
Go to a line in the current file.
l Line number
Go to a symbol definition.
: Symbol name
Go to a help topic.
? Help topic
Go to an open file.
o File name
Go to a file in the file system (browse the file system).
f File name
Go to a file in any project currently open.
a File name
Go to a file in the current project.
p File name
Go to a class definition.
c Class name
Go to a method definition.
m Method name
Creating Locator Filters
To quickly access files not directly mentioned in your project, you can create your own locator filters. That way you can locate files in a directory structure you have defined.
To create a locator filter:
- In the locator, click and select Configure.... to open the Locator options.
- Click Add.
- In the Filter Configuration dialog:
- Click OK.
Configuring the Locator Cache
The locator searches the files matching your file pattern in the directories you have selected and caches that information. The cache for all default filters is updated as you write your code. By default, Qt Creator updates the filters created by you once an hour.
To update the cached information manually, click and select Refresh.
To set a new cache update time:
- Select Tools > Options... > Locator.
- In Refresh interval, define new time in minutes.