little bug when creating Q_OBJECT C++ classes
-
If I create a C++ based on the Q_OBJECT I have a little problem. I add a Q_PROPERTY with myVariable name. Then I do refactor->create missing members.
Then I compile and get an error in some C++ file starting with moc_"my class name". The error is that setMyVariable or setmyVariable does not exist. Essentially it's an issue with code that is automatically generated. The "convention" is to name a variable or function with the first word in the name starting lower case and any further words capitalized. Because functions are automatically generated by putting a word in front of the variable name, in one instance the first word of the variable name is capitalized as it is now the second word and in the other case this is missed.
I don't know if there is a better place to report bugs?
-
@Groundbounce Better to show some code about how Property is applied.
-
C Christian Ehrlicher moved this topic from General and Desktop
-
I start typing Q_PROPERTY and the Qt IDE suggests the standard list of variable and functions, I hit enter, I set the variable type to int and the variable name to myVariable.
Then I right click Q_PROPERTY and select refactor->create missing members, I then build the empty project with the empty class and the error around the exact spelling of setmyVariable() or setMyVariable are reported by the compiler in the moc_myclass.cpp file. This file is not created by me and is not in my source directory, it is auto generated and put into the build directory, I assume it deals with signals etc for me.
-
I remember having some similar issues in previous QtCreator versions.
Are you up to date with your QtCreator? what version are you using?