Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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)

like image 465
Georgy Pashkov Avatar asked Mar 31 '11 07:03

Georgy Pashkov


1 Answers

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?

like image 132
Derick Schoonbee Avatar answered Nov 15 '22 17:11

Derick Schoonbee