Results 1 to 4 of 4

Thread: Change code style for C++

  1. #1
    Join Date
    Apr 2011
    Posts
    16
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Change code style for C++

    hello, i use qt sdk 1.2 and i have a question, how do i change the code style for c++? I can't find "advanced" functions or options to do it in Qt creator, it just shows indent or not a bracket or something like that, i dont like this:
    Qt Code:
    1. void method()
    2. {
    3. //code
    4. }
    To copy to clipboard, switch view to plain text mode 

    or

    Qt Code:
    1. myClass::myClass()
    2. : var(value)
    3. {
    4. //code
    5. }
    To copy to clipboard, switch view to plain text mode 

    i prefer

    Qt Code:
    1. myClass::myClass() : var(value) {
    2. //code
    3. }
    To copy to clipboard, switch view to plain text mode 

    i'm talking about creating a new class or using "refactor" to add a definition, i know i can type my code using my favorite style but i don't want to do it manually when creating a class or something like that
    thanks

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Change code style for C++

    See the 'Settings' dialog, the "C++" pane. Click on "Edit" and have fun.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  3. #3
    Join Date
    Jul 2012
    Posts
    1
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Change code style for C++

    Quote Originally Posted by wysota View Post
    See the 'Settings' dialog, the "C++" pane. Click on "Edit" and have fun.
    Apologies for the thread necromancy, but since I don't see this discussed anywhere else: the code style options in Qt Creator (at least as of Qt Creator 2.4.1) don't offer any obvious way to place braces on the same line as the method signature ("K&R style") as the OP requested. They also don't offer options for the binding of asterisks and ampersands (const Foo& bar vs. const Foo &bar), use of NULL vs. 0, and a number of other things that I have to correct every time Creator makes a new class boilerplate. Am I missing something? If not, do you know if there are plans to expand these options in the future?

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Change code style for C++

    Much has changed since then. I don't see those options anywhere either.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


Similar Threads

  1. How To Change Style Sheet for QCalendarWidget
    By jthacker in forum Qt Programming
    Replies: 15
    Last Post: 4th March 2016, 15:28
  2. Replies: 2
    Last Post: 24th August 2011, 09:45
  3. Qt Style Sheet Vs Code
    By Ashutosh2k1 in forum Qt Programming
    Replies: 4
    Last Post: 4th May 2011, 06:45
  4. Replies: 2
    Last Post: 9th January 2010, 16:41
  5. How to change the style of QTabWidget
    By iamjayanth in forum Qt Programming
    Replies: 1
    Last Post: 24th April 2009, 12:07

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.