Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

[Solved]Edit the codeStyle of Qt Creator



  • 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?


  • Lifetime Qt Champion

    Hi,

    Preferences -> C++ -> Code Style

    Hope it helps



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


  • Lifetime Qt Champion

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


Log in to reply