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. camel case or underscores or mixed?
Qt 6.11 is out! See what's new in the release blog

camel case or underscores or mixed?

Scheduled Pinned Locked Moved Unsolved General and Desktop
5 Posts 5 Posters 3.9k Views 5 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.
  • G Offline
    G Offline
    Goddard
    wrote on last edited by
    #1

    I noticed Qt creator uses mixed styles and I was wondering if a reason existed for this.

    It generates signals/slots that use underscores and all classes and functions seem to be camel case. Is this standard? Is this what I should do as a Qt developer?

    Is this in the docs some where?

    Thanks

    JKSHJ 1 Reply Last reply
    0
    • Paul ColbyP Offline
      Paul ColbyP Offline
      Paul Colby
      wrote on last edited by
      #2

      Hi @Goddard,

      It generates signals/slots that use underscores and all classes and functions seem to be camel case.

      What do you mean by it "generates signal/slots"? I'm a bit of a Qt Creator n00b - just use it as a glorified text editor most of the time, so I'm not familiar with its code generation abilities, but what you describe does sound odd.

      Is this standard? Is this what I should do as a Qt developer?

      I'd say not. Most (all?) of the Qt classes use camelCase for signals; eg QObject::objectNameChanged.

      It generates signals/slots that use underscores and all classes and functions seem to be camel case.

      So while you're welcome (AFAIK) to use any style you like, I certainly wouldn't say underscores are recommended just based on whatever Qt Creator behaviour you're seeing.

      Cheers.

      1 Reply Last reply
      0
      • G Goddard

        I noticed Qt creator uses mixed styles and I was wondering if a reason existed for this.

        It generates signals/slots that use underscores and all classes and functions seem to be camel case. Is this standard? Is this what I should do as a Qt developer?

        Is this in the docs some where?

        Thanks

        JKSHJ Offline
        JKSHJ Offline
        JKSH
        Moderators
        wrote on last edited by
        #3

        @Paul Colby

        What do you mean by it "generates signal/slots"?

        See http://doc.qt.io/qt-5/designer-using-a-ui-file.html#widgets-and-dialogs-with-auto-connect

        @Goddard said:

        It generates signals/slots that use underscores and all classes and functions seem to be camel case. Is this standard? Is this what I should do as a Qt developer?

        As a developer in general, you are free to do whatever you want. Pick your preferred style and stick to it. The most important thing is to be consistent.

        Qt Designer's auto-connector uses underscores. Unfortunately, this is inconsistent with Qt's coding conventions. Qt's public API uses camel casing only, not underscores.

        Personally, I don't use the auto-connector.

        I noticed Qt creator uses mixed styles and I was wondering if a reason existed for this.

        No good reason, really.

        Qt Doc Search for browsers: forum.qt.io/topic/35616/web-browser-extension-for-improved-doc-searches

        kshegunovK 1 Reply Last reply
        2
        • JKSHJ JKSH

          @Paul Colby

          What do you mean by it "generates signal/slots"?

          See http://doc.qt.io/qt-5/designer-using-a-ui-file.html#widgets-and-dialogs-with-auto-connect

          @Goddard said:

          It generates signals/slots that use underscores and all classes and functions seem to be camel case. Is this standard? Is this what I should do as a Qt developer?

          As a developer in general, you are free to do whatever you want. Pick your preferred style and stick to it. The most important thing is to be consistent.

          Qt Designer's auto-connector uses underscores. Unfortunately, this is inconsistent with Qt's coding conventions. Qt's public API uses camel casing only, not underscores.

          Personally, I don't use the auto-connector.

          I noticed Qt creator uses mixed styles and I was wondering if a reason existed for this.

          No good reason, really.

          kshegunovK Offline
          kshegunovK Offline
          kshegunov
          Moderators
          wrote on last edited by kshegunov
          #4

          @Goddard

          It generates signals/slots that use underscores and all classes and functions seem to be camel case. Is this standard? Is this what I should do as a Qt developer?

          I personally prefer camelcase, as underscore reminds me too much of C and its many quirks, and to be honest I don't see adding extra underscores as improvement on readability. Still, as JKSH said, it's just a matter of preference and you're free to choose what suits you best.

          @JKSH said:

          Personally, I don't use the auto-connector.

          Too magic for me either ...

          Read and abide by the Qt Code of Conduct

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

            After some time working with a giant project that uses Qt, MFC, STL nad WinAPI in different parts all I can say is that naming convention doesn't really make a difference, just do yourself a giant favor and pick one and stick to it.

            And I wouldn't use the auto connection feature. It might be tempting for people used to visual designers like in C# or Delphi, but it's quite different in details and not particularly good for maintenance anyway (renaming, refactoring etc).

            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