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 customize settings for creating getter and setter methods?
QtWS25 Last Chance

How to customize settings for creating getter and setter methods?

Scheduled Pinned Locked Moved Solved Qt Creator and other tools
3 Posts 3 Posters 2.5k 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.
  • S Offline
    S Offline
    Suares
    wrote on last edited by Suares
    #1

    By default for

    class X
    {
    private:
    	int x_;
    };
    

    We get

    class X
    {
    public:
    	int x() const;
    	void setX(int x);
    	
    private:
    	int x_;
    };
    

    But I would like generating these two methods in another way:

    1. I like when each method starts from the capital letter.
    2. Getter method starts from "Get" word.

    Thanks!

    1 Reply Last reply
    0
    • Chris KawaC Online
      Chris KawaC Online
      Chris Kawa
      Lifetime Qt Champion
      wrote on last edited by
      #2

      The style used is what Qt uses. Unfortunately it is hardcoded so there's no way to change it except by modifying the source and compiling Qt Creator yourself (or just the cppeditor plugin).

      1 Reply Last reply
      1
      • S Offline
        S Offline
        stan.m
        wrote on last edited by
        #3

        Check the Qt Creator instructions for snippets.

        I just followed the instructions and modified the auto-completed code for Q_PROPERTY so that the getter follows my company's coding style of "get" + Uppercased property name.

        You can probably create a snippet for what you want.

        1 Reply Last reply
        0

        • Login

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