Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. [Solved]Edit the codeStyle of Qt Creator
Forum Updated to NodeBB v4.3 + New Features

[Solved]Edit the codeStyle of Qt Creator

Scheduled Pinned Locked Moved General and Desktop
4 Posts 2 Posters 1.1k 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.
  • S Offline
    S Offline
    stereomatching
    wrote on last edited by
    #1

    Play with the boost::phoenix, the problem is that the default code style of Qt Creator cannot align the codes very well.

    expected
    @
    int main()
    {
    using boost::phoenix::if_;
    using boost::phoenix::arg_names::arg1;

    int init[] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
    std::vector<int> v(init, init+10);
    
    std::cout << std::dec;
    int x = 0;
    
    std::for_each(v.begin(), v.end(),
        if_(arg1 > 5)
        [
            std::cout << arg1 << ", "
        ]
    );
    
    std::cout << std::endl;
    
    return 0;
    

    }
    @

    result
    @
    void test_if()
    {
    using boost::phoenix::if_;
    using boost::phoenix::arg_names::arg1;

    std::vector<int> const v{ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
    
    std::cout << std::dec;
    std::for_each(v.begin(), v.end(),
                  if_(arg1 > 5)
                  [
                  std::cout << arg1 << ", "
                               ]
                               );
    
    std::cout << std::endl;
    

    }
    @

    How should I edit the code type so the Qt Creator can make the codes easier to read?

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      Preferences -> C++ -> Code Style

      Hope it helps

      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
      0
      • S Offline
        S Offline
        stereomatching
        wrote on last edited by
        #3

        SGaist, thanks. But how should I edit it?Any example to reference?

        1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          Call copy on the current scheme and then edit and you should be good to go

          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
          0

          • Login

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