Georgy Pashkov
Georgy Pashkov

Reputation: 1304

Broken indentation for Qt-specific constructions in Visual Studio

Automatic indentation in VS editor obviously does not know about Qt. And declarations of signals and slots are auto-formatted like this:

   class MyClass : public QObject
   {
   Q_OBJECT
   public:
      MyClass();

signals: // <-- Broken indentation
      void someSignal();

      public slots: // <-- Also broken
         void someSlot();
   };

I want "signals:" and "slots:" automatically formatted just like access specifiers. What are the options? (I'm using VS2010)

Upvotes: 9

Views: 720

Answers (1)

Derick Schoonbee
Derick Schoonbee

Reputation: 3021

In short answer seems to be 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();
   };

(It's ugly but it seems you can't have your cake and eat it too ;)

Just something I'm wondering about: Is it worth the effort to build a plugin for automatic formatting? Do we really use CTRL-A CTRL-F so much? If so, then yes it could be a pain. But normally if you are working on header files declaring a new method (signal or slot) should not mess up the previous corrected indentation. Perhaps you have some reasons that justifies this?

Upvotes: 7

Related Questions