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. automatic formatting of try-catch
QtWS25 Last Chance

automatic formatting of try-catch

Scheduled Pinned Locked Moved Solved Qt Creator and other tools
editorautoformatcreator
4 Posts 3 Posters 812 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.
  • D Offline
    D Offline
    dave2
    wrote on 23 Aug 2020, 17:03 last edited by
    #1

    I use Qt Creator 4.12.4 on Windows 10.

    When I type:

    try
    

    Qt Creator brings up a pop-up menu where the first item is "try{}catch(){}". When I select this item, Qt Creator automatically adds the following code:

    try {
        
    } catch () {
        
    }
    

    Is it possible to change the settings so the code would be:

    try
    {
        
    }
    catch ()
    {
        
    }
    

    ?

    I was unable to find any setting for doing that in the "C++" part of the "Options - Qt Creator" dialog.

    A 1 Reply Last reply 24 Aug 2020, 07:15
    0
    • D dave2
      23 Aug 2020, 17:03

      I use Qt Creator 4.12.4 on Windows 10.

      When I type:

      try
      

      Qt Creator brings up a pop-up menu where the first item is "try{}catch(){}". When I select this item, Qt Creator automatically adds the following code:

      try {
          
      } catch () {
          
      }
      

      Is it possible to change the settings so the code would be:

      try
      {
          
      }
      catch ()
      {
          
      }
      

      ?

      I was unable to find any setting for doing that in the "C++" part of the "Options - Qt Creator" dialog.

      A Offline
      A Offline
      aha_1980
      Lifetime Qt Champion
      wrote on 24 Aug 2020, 07:15 last edited by
      #3

      Hi @dave2,

      Actually there are two items, the second one try and catch is a snippet, so you can adjust it: Tools > Options > Text Editor > Snippets > C++

      The first one try {} catch () {} seems to come from Clang and can not be changed, AFAIK.

      Regards

      Qt has to stay free or it will die.

      D 1 Reply Last reply 24 Aug 2020, 18:51
      1
      • C Offline
        C Offline
        Christian Ehrlicher
        Lifetime Qt Champion
        wrote on 23 Aug 2020, 18:24 last edited by
        #2

        Use an automatic styler when saving the file (e.g. beautifier plugin) and don't worry about the formatting anymore.

        Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
        Visit the Qt Academy at https://academy.qt.io/catalog

        1 Reply Last reply
        0
        • D dave2
          23 Aug 2020, 17:03

          I use Qt Creator 4.12.4 on Windows 10.

          When I type:

          try
          

          Qt Creator brings up a pop-up menu where the first item is "try{}catch(){}". When I select this item, Qt Creator automatically adds the following code:

          try {
              
          } catch () {
              
          }
          

          Is it possible to change the settings so the code would be:

          try
          {
              
          }
          catch ()
          {
              
          }
          

          ?

          I was unable to find any setting for doing that in the "C++" part of the "Options - Qt Creator" dialog.

          A Offline
          A Offline
          aha_1980
          Lifetime Qt Champion
          wrote on 24 Aug 2020, 07:15 last edited by
          #3

          Hi @dave2,

          Actually there are two items, the second one try and catch is a snippet, so you can adjust it: Tools > Options > Text Editor > Snippets > C++

          The first one try {} catch () {} seems to come from Clang and can not be changed, AFAIK.

          Regards

          Qt has to stay free or it will die.

          D 1 Reply Last reply 24 Aug 2020, 18:51
          1
          • A aha_1980
            24 Aug 2020, 07:15

            Hi @dave2,

            Actually there are two items, the second one try and catch is a snippet, so you can adjust it: Tools > Options > Text Editor > Snippets > C++

            The first one try {} catch () {} seems to come from Clang and can not be changed, AFAIK.

            Regards

            D Offline
            D Offline
            dave2
            wrote on 24 Aug 2020, 18:51 last edited by
            #4

            @aha_1980 This is exactly, not almost, what I was looking for. Thanks a lot!

            1 Reply Last reply
            1

            1/4

            23 Aug 2020, 17:03

            • Login

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