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. How to configure Qt Creator code completion configuration for else {}
QtWS25 Last Chance

How to configure Qt Creator code completion configuration for else {}

Scheduled Pinned Locked Moved Unsolved Qt Creator and other tools
5 Posts 3 Posters 817 Views
  • 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.
  • J Offline
    J Offline
    Jeff Barnes
    wrote on last edited by
    #1

    Qt Creator 4.8.0
    Based on Qt 5.12.0 (GCC 5.3.1 20160406 (Red Hat 5.3.1-6), 64 bit)

    When I type if (condition), I can press return and insert a bracket and it lines up to my liking.
    For example

        if (someCondition)
        {
        }
    

    But if I type else, code completion thinks I want the open bracket on the same line. Is there a way to configure this? My code ends up like the following, which I then have to edit to my liking.

        if (someCondition)
        {
            doSomething();
        }
        else {
            goBackAndEditTheElseDeclaration();
        }
    
    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      You are likely looking for this part of Qt Creator's documentation.

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      3
      • J Offline
        J Offline
        Jeff Barnes
        wrote on last edited by Jeff Barnes
        #3

        In Code Style under Project Settings, I see the Current settings says Global [proxy: Qt]. The preview shows the following, which is what I want, but is not what happens.

                if (i < b)
                    bar(i);
                else
                {
                    bar(i);
                    bar(b);
                }
        
        

        Again, this is code completion behavior. If I go back to the else line and move the bracket to the next line by typing <Enter> before the bracket, it behaves per settings.

        BTW this is new behavior with 4.8.0.

        aha_1980A 1 Reply Last reply
        0
        • J Jeff Barnes

          In Code Style under Project Settings, I see the Current settings says Global [proxy: Qt]. The preview shows the following, which is what I want, but is not what happens.

                  if (i < b)
                      bar(i);
                  else
                  {
                      bar(i);
                      bar(b);
                  }
          
          

          Again, this is code completion behavior. If I go back to the else line and move the bracket to the next line by typing <Enter> before the bracket, it behaves per settings.

          BTW this is new behavior with 4.8.0.

          aha_1980A Offline
          aha_1980A Offline
          aha_1980
          Lifetime Qt Champion
          wrote on last edited by
          #4

          @Jeff-Barnes i noticed this new behavior too, but only on Linux so far. I just didnt manage to report a bug so far. In case you want to do: bugreports.qt.io (and please add a link here).

          Qt has to stay free or it will die.

          aha_1980A 1 Reply Last reply
          1
          • aha_1980A aha_1980

            @Jeff-Barnes i noticed this new behavior too, but only on Linux so far. I just didnt manage to report a bug so far. In case you want to do: bugreports.qt.io (and please add a link here).

            aha_1980A Offline
            aha_1980A Offline
            aha_1980
            Lifetime Qt Champion
            wrote on last edited by
            #5

            Continued as QTCREATORBUG-21767

            Qt has to stay free or it will die.

            1 Reply Last reply
            2

            • Login

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