Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 104946

Summary: [Help Wanted] Support QT language variant
Product: [Tools] CDT Reporter: Joerg Reiling <Joerg.Reiling>
Component: cdt-parserAssignee: Project Inbox <cdt-core-inbox>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: cdtdoug, eclipse, espinosa_cz, lykurg, vince.negri, zeratul976
Version: 3.0Keywords: helpwanted
Target Milestone: ---   
Hardware: PC   
OS: Windows 2000   
Whiteboard:

Description Joerg Reiling CLA 2005-07-24 13:11:26 EDT
If a class declaration uses the Qt-keyword "privat slot:", the "Ouline view" of
this class will disappear.
I know, that the keyword "slot" is not Ansi-C/C++...but for Qt-programmers it
would be very nice, if this keyword would be supported.

Regards Jörg
Comment 1 Vince Negri CLA 2006-07-08 07:13:21 EDT
This behaves in the same way in CDT 3.1

Basically, I presume the "Outline view" uses a quick parser looking at just the file, as opposed to referencing the PDOM (which makes sense since doing the latter would slow down opening a new file.)

The O_OBJECT macro also causes similar problems.

I think, though, that this issue could be cleared up by adding a project-local option along these lines:

"Outline view #defines"

where the option is a list (maybe in -Dfoo=bar format??) of macro substitutions the outline viewer assumes to be in place.

For example, for QT the following will make the outline view look "right"

-DQ_OBJECT= -Dslots= -Dsignals=protected

Comment 2 Vince Negri CLA 2006-07-08 07:35:37 EDT
Here's a kludgy workaround, assuming your project is a standard makefile project and not a managed one.

Go into Project Properties, C++ Include Paths and symbols. Click on "Add Preprocessor Symbol" and create a new symbol "__ECLIPSE__=1" - this symbol will be visible to Eclipse but not to gnu make or gcc.

Now in your QT header file, just before the class definition, paste:

#if __ECLIPSE__
#define Q_OBJECT
#define slots
#define signals protected
#endif

and viola! The outline view looks "correct", but the build and Indexer still work as before.

Of course this is ugly and forces you to modify the source. Possibly you can put the three macros above directly into the preprocessor symbols, but I don't knwo if that might break the indexing of the QT header files.
Comment 3 Chris Recoskie CLA 2007-05-11 14:18:50 EDT
It should be possible now with the new work on language extensibility we did for CDT 4.0 to contribute a new ILanguage for QT, if anyone is interested in working on it.
Comment 4 Doug Schaefer CLA 2007-08-21 11:00:22 EDT
Future means you commit to fix it in the Future. Inboxes can't make committments. Moving to '--'.
Comment 5 Anton Leherbauer CLA 2007-10-02 06:47:15 EDT
*** Bug 204055 has been marked as a duplicate of this bug. ***
Comment 6 Doug Schaefer CLA 2007-10-02 09:47:51 EDT
I'm actually surprised this doesn't work. The outline view does use the indexer now. It should be getting the macro definitions for these keywords from there.

I don't use Qt. Can someone confirm whether this is still a problem with 4.0?
Comment 7 Espinosa CZ CLA 2007-10-02 18:22:43 EDT
.I don't know if it is related but in
Outline view seems to be mostly working, BUT it omits some fields for me. 
See this example from kdenlive.h

      private:
		/** the configuration object of the application */
	 KConfig * config;
		/** The "view" is the base widget for the entire application. */
	QWidget *view;


Member variable "config" is not "displayed" in outline, widget yes. Why?
My bug 204055 was marked as duplication so that why I am interested in this too.
Comment 8 Espinosa CZ CLA 2007-10-02 18:24:27 EDT
Sorry the spelling, was:

I don't know if it is related. Outline view seems to be mostly working, at least for me BUT it omits some fields. 
Comment 9 Lykurg CLA 2007-10-04 11:51:40 EDT
Hi, I just saw, that the source format and "private slot:" works with only correct if you include QWidget. When including QtGui alone, the format brakes. (I using 4.0.1; I200709251200).
Comment 10 Nathan Ridge CLA 2013-12-15 20:20:06 EST
I know some work on Qt support for CDT has been done recently. Is this bug still relevant?
Comment 11 Doug Schaefer CLA 2013-12-23 18:41:30 EST
Actually. I don't think this is a problem anymore. The slot keyword is handled by a macro which defines it to nothing. If the scanner info is set up correctly, the outline view shouldn't break.

I'll mark this fixed. There are other bugs we've opened and fixed to make Qt a first class citizen in CDT. Still a work in progress so if you see anything, please raise it.