Author Topic: Formatting problem with Qt code  (Read 2882 times)

microcode

  • Community Member
  • Posts: 59
  • Hero Points: 10
Formatting problem with Qt code
« on: January 17, 2013, 11:30:50 PM »
I have the following two problems with formatting C++ code for Qt:

1. When trying to type "public slots:", the space character causes SlickEdit to automatically enter a colon instead, so the line becomes "public:slots:" and I have to go back and manually change the colon to a space.  I was able to change this behavior in an older version of SE, but I can't figure out a solution in SE v17.0.3.

2. When I use the beautify function, lines like "public slots:" or "signals:" get indented rather than being put in column 1 like the standard access specifiers.  And sometimes the function prototypes under them get indented an extra level.  See the example below.  What's causing this, and how can I get the beautifier to not indent the special Qt lines like the standard C++ access specifiers are not indented?

Code: [Select]
class Example : public QObject
{
    Q_OBJECT;

public:
    explicit Example( QObject * parent = 0 );
    virtual ~Example();

    public slots:
    void someSlot();

    signals:
        void someSignal();

protected:
    virtual void doSomething();
};

I want it look like this:

Code: [Select]
class Example : public QObject
{
    Q_OBJECT;

public:
    explicit Example( QObject * parent = 0 );
    virtual ~Example();

public slots:
    void someSlot();

signals:
    void someSignal();

protected:
    virtual void doSomething();
};

Matthew

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 990
  • Hero Points: 44
Re: Formatting problem with Qt code
« Reply #1 on: January 18, 2013, 04:57:02 PM »
1. If you press Shift+Space, you'll avoid the auto-insertion. You can do this anywhere where you don't want a space to trigger an autocomplete or syntax expansion.
The options you're thinking of ("Expand aliases on space" and "Use Syntax Expansion on space")  are in the Auto-Complete sections of the per-language settings. You can also tweak it globally under Languages > All Languages > Autocomplete. But I think Shift+Space as needed is the way to go.

2. We would need to special case the "public slots:", "protected signals:", etc behavior for Qt.