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. When changing the object name in qt designer, even the variable name is changed
Forum Updated to NodeBB v4.3 + New Features

When changing the object name in qt designer, even the variable name is changed

Scheduled Pinned Locked Moved Solved General and Desktop
5 Posts 3 Posters 1.9k 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.
  • I Offline
    I Offline
    IknowQT
    wrote on 10 Mar 2022, 08:24 last edited by
    #1
    • ui_widget
    tableWidget = new usrTableWidget(frm_Table);
            tableWidget->setObjectName(QString::fromUtf8("tableWidget"));
            tableWidget->setStyleSheet(QString::fromUtf8(""));
            tableWidget->setShowGrid(true);
    
            horizontalLayout_6->addWidget(tableWidget);
    

    Is there a way to change only setObjectName on the designer surface?

    84355c1f-0a6c-49d1-a56a-21ad75381857-image.png

    The object name on the screen is related to the variable name.

    C 1 Reply Last reply 10 Mar 2022, 08:50
    0
    • I IknowQT
      10 Mar 2022, 23:06

      @Christian-Ehrlicher

      If it can be changed programmatically, I think there is no reason why it can't be changed in the designer.

      P Offline
      P Offline
      Pl45m4
      wrote on 10 Mar 2022, 23:33 last edited by Pl45m4 3 Oct 2022, 23:54
      #4

      @IknowQT said in When changing the object name in qt designer, even the variable name is changed:

      I think there is no reason why it can't be changed in the designer.

      Because you access the gui elements from your uic compiled header by using the object name given in QtDesigner (your .ui file).

      In addition you can set/change object name with your code. IIRC objects you create in your classes dont have a object name by default... So why should there only be one way?
      setObjectname has to stay in and without a object name set by QtDesigner in your ui file, you would not be able to use these files and do some default connections (access elements from UI file directly using the UI pointer). uic creates the designer object variables based on their object names and sets the object name in the resulting header file.

      Edit:

      The explanation above is a bit clunky :)
      The reason is, that uic takes the name from your UI file and creates your compiled ui_xxx.h header... In this header, your pre-designed objects have a object name and variable name which is equivalent to the object name in your design file... QtDesigner / UIC is not responsible for changes you make afterwards...

      Like @Christian-Ehrlicher said... What's the point of having/explicitly wanting different names?


      If debugging is the process of removing software bugs, then programming must be the process of putting them in.

      ~E. W. Dijkstra

      I 1 Reply Last reply 11 Mar 2022, 06:20
      2
      • I IknowQT
        10 Mar 2022, 08:24
        • ui_widget
        tableWidget = new usrTableWidget(frm_Table);
                tableWidget->setObjectName(QString::fromUtf8("tableWidget"));
                tableWidget->setStyleSheet(QString::fromUtf8(""));
                tableWidget->setShowGrid(true);
        
                horizontalLayout_6->addWidget(tableWidget);
        

        Is there a way to change only setObjectName on the designer surface?

        84355c1f-0a6c-49d1-a56a-21ad75381857-image.png

        The object name on the screen is related to the variable name.

        C Online
        C Online
        Christian Ehrlicher
        Lifetime Qt Champion
        wrote on 10 Mar 2022, 08:50 last edited by
        #2

        @IknowQT said in When changing the object name in qt designer, even the variable name is changed:

        The object name on the screen is related to the variable name.

        And what's wrong with it?
        If you want another object name than the variable name (for unknown reason) then you have to set it programatically.

        Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
        Visit the Qt Academy at https://academy.qt.io/catalog

        I 1 Reply Last reply 10 Mar 2022, 23:06
        3
        • C Christian Ehrlicher
          10 Mar 2022, 08:50

          @IknowQT said in When changing the object name in qt designer, even the variable name is changed:

          The object name on the screen is related to the variable name.

          And what's wrong with it?
          If you want another object name than the variable name (for unknown reason) then you have to set it programatically.

          I Offline
          I Offline
          IknowQT
          wrote on 10 Mar 2022, 23:06 last edited by
          #3

          @Christian-Ehrlicher

          If it can be changed programmatically, I think there is no reason why it can't be changed in the designer.

          P 1 Reply Last reply 10 Mar 2022, 23:33
          0
          • I IknowQT
            10 Mar 2022, 23:06

            @Christian-Ehrlicher

            If it can be changed programmatically, I think there is no reason why it can't be changed in the designer.

            P Offline
            P Offline
            Pl45m4
            wrote on 10 Mar 2022, 23:33 last edited by Pl45m4 3 Oct 2022, 23:54
            #4

            @IknowQT said in When changing the object name in qt designer, even the variable name is changed:

            I think there is no reason why it can't be changed in the designer.

            Because you access the gui elements from your uic compiled header by using the object name given in QtDesigner (your .ui file).

            In addition you can set/change object name with your code. IIRC objects you create in your classes dont have a object name by default... So why should there only be one way?
            setObjectname has to stay in and without a object name set by QtDesigner in your ui file, you would not be able to use these files and do some default connections (access elements from UI file directly using the UI pointer). uic creates the designer object variables based on their object names and sets the object name in the resulting header file.

            Edit:

            The explanation above is a bit clunky :)
            The reason is, that uic takes the name from your UI file and creates your compiled ui_xxx.h header... In this header, your pre-designed objects have a object name and variable name which is equivalent to the object name in your design file... QtDesigner / UIC is not responsible for changes you make afterwards...

            Like @Christian-Ehrlicher said... What's the point of having/explicitly wanting different names?


            If debugging is the process of removing software bugs, then programming must be the process of putting them in.

            ~E. W. Dijkstra

            I 1 Reply Last reply 11 Mar 2022, 06:20
            2
            • P Pl45m4
              10 Mar 2022, 23:33

              @IknowQT said in When changing the object name in qt designer, even the variable name is changed:

              I think there is no reason why it can't be changed in the designer.

              Because you access the gui elements from your uic compiled header by using the object name given in QtDesigner (your .ui file).

              In addition you can set/change object name with your code. IIRC objects you create in your classes dont have a object name by default... So why should there only be one way?
              setObjectname has to stay in and without a object name set by QtDesigner in your ui file, you would not be able to use these files and do some default connections (access elements from UI file directly using the UI pointer). uic creates the designer object variables based on their object names and sets the object name in the resulting header file.

              Edit:

              The explanation above is a bit clunky :)
              The reason is, that uic takes the name from your UI file and creates your compiled ui_xxx.h header... In this header, your pre-designed objects have a object name and variable name which is equivalent to the object name in your design file... QtDesigner / UIC is not responsible for changes you make afterwards...

              Like @Christian-Ehrlicher said... What's the point of having/explicitly wanting different names?

              I Offline
              I Offline
              IknowQT
              wrote on 11 Mar 2022, 06:20 last edited by
              #5

              @Pl45m4

              I was trying to apply a style sheet, but there was a way to apply a style by object name. While testing it, I asked a question because I thought it would be easier to change it in a design tool rather than changing it by programming.

              1 Reply Last reply
              0

              1/5

              10 Mar 2022, 08:24

              • Login

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