Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt Creator and other tools
  4. Built-in code style is not compatible to the Qt style guide
Forum Updated to NodeBB v4.3 + New Features

Built-in code style is not compatible to the Qt style guide

Scheduled Pinned Locked Moved Qt Creator and other tools
9 Posts 2 Posters 5.2k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    messi
    wrote on 2 Aug 2012, 14:02 last edited by
    #1

    Hi there

    I'm wondering why the built-in code style in Qt-Creator is not like the one from Coding Guidelines.
    http://doc.qt.nokia.com/qtcreator-extending/coding-style.html

    I'm curious why the Qt Code Guideline is using the K&R style which was invented when people used to program with vt100 terminals.

    I'm more fan of the Allman style but since this violates the Qt Coding Guideline I try to switch to the K&R.
    http://en.wikipedia.org/wiki/Indent_style

    But as I mentioned in the beginning, why is the Qt built-in code style set to Allmann instead of K&R?
    It looks a little bit inconsistent.

    Best regards

    messi

    1 Reply Last reply
    1
    • T Offline
      T Offline
      tobias.hunger
      wrote on 3 Aug 2012, 15:03 last edited by
      #2

      I fail to see the problem:-)

      1 Reply Last reply
      0
      • M Offline
        M Offline
        messi
        wrote on 6 Aug 2012, 07:23 last edited by
        #3

        Tobias Hunger
        I know this post sounds a little bit picky but it is not qt coding rules conform.

        This is in the Qt Creator Coding Rules:
        Braces

        As a base rule, place the left curly brace on the same line as the start of the statement:

        @if (codec) {
        ....
        }@

        NOT

        @ if (codec)
        {
        ....
        }@

        This is the built-in code style of the qt-creator:

        @void foo(int a, int b)
        {
        for (int i = 0; i < a; i++)
        {
        if (i < b)
        bar(i);
        else
        {
        bar(i);
        bar(b);
        }
        }
        }@

        1 Reply Last reply
        0
        • T Offline
          T Offline
          tobias.hunger
          wrote on 6 Aug 2012, 10:31 last edited by
          #4

          I never noticed that! My code looks just fine with the default settings in creator, so where does this effect you?

          1 Reply Last reply
          0
          • M Offline
            M Offline
            messi
            wrote on 6 Aug 2012, 11:12 last edited by
            #5

            Actually it is not effecting me.
            But to be consistent in the rules of the build-it text under QtCrator -> Options -> C++ -> CodeStyle should like:

            @ for (int i = 0; i < a; i++) {
            if (i < b) {
            bar(i);
            } else {
            bar(i);
            bar(b);
            }
            }@

            and not like:

            @ for (int i = 0; i < a; i++)
            {
            if (i < b)
            bar(i);
            else
            {
            bar(i);
            bar(b);
            }
            }@

            Which is think is more readable then the first version.

            1 Reply Last reply
            0
            • T Offline
              T Offline
              tobias.hunger
              wrote on 7 Aug 2012, 09:21 last edited by
              #6

              I don't think this is too important: Why should an IDE enforce the coding style used to program itself on unrelated projects?

              1 Reply Last reply
              0
              • M Offline
                M Offline
                messi
                wrote on 7 Aug 2012, 09:40 last edited by
                #7

                Then would be the question, how many people use qt-creator to program qt related stuff?

                1 Reply Last reply
                0
                • T Offline
                  T Offline
                  tobias.hunger
                  wrote on 7 Aug 2012, 12:51 last edited by
                  #8

                  Note that the Qt Creator styleguide and the Qt styleguide do differ. So does the KDE style guide... and lots of other projects style guides, too.

                  Anyway: I had not even noticed that the style displayed there differs and I use Creator rather regularly to code following the Qt Creator style guide, so I don't think this is an issue.

                  1 Reply Last reply
                  0
                  • M Offline
                    M Offline
                    messi
                    wrote on 7 Aug 2012, 12:58 last edited by
                    #9

                    Sorry to say that but qt style guide and qt creator style guide are equal in that particular case.

                    1 Reply Last reply
                    0

                    1/9

                    2 Aug 2012, 14:02

                    • Login

                    • Login or register to search.
                    1 out of 9
                    • First post
                      1/9
                      Last post
                    0
                    • Categories
                    • Recent
                    • Tags
                    • Popular
                    • Users
                    • Groups
                    • Search
                    • Get Qt Extensions
                    • Unsolved