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. How to name Qlabel?
Qt 6.11 is out! See what's new in the release blog

How to name Qlabel?

Scheduled Pinned Locked Moved Unsolved General and Desktop
8 Posts 4 Posters 952 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.
  • T Offline
    T Offline
    TomNow99
    wrote on last edited by TomNow99
    #1

    Hello,

    This is not question stricte about QT, but I use QT, so... :)

    Very often I have situation when I have 2 QWidgets: QLabel and QLineEdit.

    QLabel has fixed text for example "Age:" and QLineEdit is the widget with empty place, where I can write age ( for example "32" ). How I should name that QWidgets? I know that there are different schools, but how will you name this widgets?

    I write:
    QLabel ageTextInfo;
    QLineEdit ageLineEdit;

    But I think there can be better way.

    JonBJ J.HilkJ 2 Replies Last reply
    1
    • T TomNow99

      Hello,

      This is not question stricte about QT, but I use QT, so... :)

      Very often I have situation when I have 2 QWidgets: QLabel and QLineEdit.

      QLabel has fixed text for example "Age:" and QLineEdit is the widget with empty place, where I can write age ( for example "32" ). How I should name that QWidgets? I know that there are different schools, but how will you name this widgets?

      I write:
      QLabel ageTextInfo;
      QLineEdit ageLineEdit;

      But I think there can be better way.

      JonBJ Offline
      JonBJ Offline
      JonB
      wrote on last edited by JonB
      #2

      @TomNow99
      I don't! It's not very Qt, and I'll probably be shouted at, but I cannot cope with spelling out a full widget-type at the end of the variable name, it just doesn't scan for me looking through code. I pick an abbreviation for each widget type and stick with that throughout. So without hesitation I would name these variables lblAge and leAge (or txtAge or editAge if you prefer), and I'm very happy with that :) (For whatever reason, I only adopt this pattern for GUI-widget variables.)

      1 Reply Last reply
      3
      • T TomNow99

        Hello,

        This is not question stricte about QT, but I use QT, so... :)

        Very often I have situation when I have 2 QWidgets: QLabel and QLineEdit.

        QLabel has fixed text for example "Age:" and QLineEdit is the widget with empty place, where I can write age ( for example "32" ). How I should name that QWidgets? I know that there are different schools, but how will you name this widgets?

        I write:
        QLabel ageTextInfo;
        QLineEdit ageLineEdit;

        But I think there can be better way.

        J.HilkJ Offline
        J.HilkJ Offline
        J.Hilk
        Moderators
        wrote on last edited by
        #3

        @TomNow99 since there's no guarantee, that the actual widget types stay during the whole of the development (for example you could change from a lineEdit to a textedit or to a custom widget) and I don't want misleading names or want to have to rename everything, I would go with

        ageInfo
        ageEdit


        Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


        Q: What's that?
        A: It's blue light.
        Q: What does it do?
        A: It turns blue.

        JonBJ 1 Reply Last reply
        2
        • J.HilkJ J.Hilk

          @TomNow99 since there's no guarantee, that the actual widget types stay during the whole of the development (for example you could change from a lineEdit to a textedit or to a custom widget) and I don't want misleading names or want to have to rename everything, I would go with

          ageInfo
          ageEdit

          JonBJ Offline
          JonBJ Offline
          JonB
          wrote on last edited by JonB
          #4

          @J-Hilk said in How to name Qlabel?:

          since there's no guarantee, that the actual widget types stay during the whole of the development (for example you could change from a lineEdit to a textedit or to a custom widget) and I don't want misleading names or want to have to rename everything

          That's what Creator Rename Symbol Under Cursor is for ;-) But of course each to their own.

          J.HilkJ 1 Reply Last reply
          0
          • JonBJ JonB

            @J-Hilk said in How to name Qlabel?:

            since there's no guarantee, that the actual widget types stay during the whole of the development (for example you could change from a lineEdit to a textedit or to a custom widget) and I don't want misleading names or want to have to rename everything

            That's what Creator Rename Symbol Under Cursor is for ;-) But of course each to their own.

            J.HilkJ Offline
            J.HilkJ Offline
            J.Hilk
            Moderators
            wrote on last edited by
            #5

            @JonB well, yes, but will the new name fit neatly into all your indentions ? 😅
            Also I don't like to rely on thus macros, if I can avoid it!


            Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


            Q: What's that?
            A: It's blue light.
            Q: What does it do?
            A: It turns blue.

            mrjjM 1 Reply Last reply
            0
            • J.HilkJ J.Hilk

              @JonB well, yes, but will the new name fit neatly into all your indentions ? 😅
              Also I don't like to rely on thus macros, if I can avoid it!

              mrjjM Offline
              mrjjM Offline
              mrjj
              Lifetime Qt Champion
              wrote on last edited by
              #6

              @J-Hilk
              Rename Symbol Under Cursor is not a macro :)
              It uses clang AST to do exact replacements on the actual variable.
              so no whops as with text-based search and replace :)

              J.HilkJ 1 Reply Last reply
              2
              • mrjjM mrjj

                @J-Hilk
                Rename Symbol Under Cursor is not a macro :)
                It uses clang AST to do exact replacements on the actual variable.
                so no whops as with text-based search and replace :)

                J.HilkJ Offline
                J.HilkJ Offline
                J.Hilk
                Moderators
                wrote on last edited by
                #7

                @mrjj said in How to name Qlabel?:

                @J-Hilk
                Rename Symbol Under Cursor is not a macro :)
                It uses clang AST to do exact replacements on the actual variable.
                so no whops as with text-based search and replace :)

                Fair enough,

                and since there is absolutely no problem with clang in QtCreator (🙈), I will have not to worry about something going wrong 😉


                Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


                Q: What's that?
                A: It's blue light.
                Q: What does it do?
                A: It turns blue.

                mrjjM 1 Reply Last reply
                1
                • J.HilkJ J.Hilk

                  @mrjj said in How to name Qlabel?:

                  @J-Hilk
                  Rename Symbol Under Cursor is not a macro :)
                  It uses clang AST to do exact replacements on the actual variable.
                  so no whops as with text-based search and replace :)

                  Fair enough,

                  and since there is absolutely no problem with clang in QtCreator (🙈), I will have not to worry about something going wrong 😉

                  mrjjM Offline
                  mrjjM Offline
                  mrjj
                  Lifetime Qt Champion
                  wrote on last edited by
                  #8

                  @J-Hilk
                  hehe i know what you mean...
                  but oddly enough the replace function is very reliable compared to clang code model in general.
                  7-9-13 is has not yet fuxed up something that was not my own fault.
                  It shows a checkable hit list and one has superfine control of what gets replaced.
                  But its more safe if one has a naming that wont need refactoring if widget type changes. :)

                  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