Broken indent for Qt-specific constructs in Visual Studio

Auto-indentation in the VS editor is clearly unaware of Qt. And the announcements of signals and slots are automatically formatted as follows:

class MyClass : public QObject { Q_OBJECT public: MyClass(); signals: // <-- Broken indentation void someSignal(); public slots: // <-- Also broken void someSlot(); }; 

I want the β€œsignals:” and β€œslots:” to be automatically formatted just like access specifiers. What are the options? (I am using VS2010)

+8
c ++ editor indentation qt visual-studio
source share
1 answer

The short answer seems NO. Maybe not what you are looking for, but maybe you can live with this:

 class MyClass : public QObject { Q_OBJECT public: MyClass(); private: Q_SIGNAL void someSignal(); public: Q_SLOT void someSlot(); }; 

(This is ugly, but it seems that you cannot have a cake and eat it;)

Just what interests me: is it worth building a plugin for automatic formatting? Are we really using CTRL-A CTRL-F? If yes, then yes, it can be a pain. But usually, if you are working on header files by declaring a new method (signal or slot), you should not ruin the previous fixed indent. Perhaps you have some reasons that justify this?

+6
source share

All Articles