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. Accessing form element's properties
Forum Update on Monday, May 27th 2025

Accessing form element's properties

Scheduled Pinned Locked Moved Unsolved General and Desktop
9 Posts 4 Posters 452 Views
  • 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.
  • A Offline
    A Offline
    AI_Messiah
    wrote on last edited by
    #1

    This is the one thing I hate about QT is that I don't know how to do this so I thought I would ask. It for some reason is not as easy as people show. For them the item just auto completes for me I have tried everything I can think of to do this.

    jsulmJ 1 Reply Last reply
    0
    • A AI_Messiah

      This is the one thing I hate about QT is that I don't know how to do this so I thought I would ask. It for some reason is not as easy as people show. For them the item just auto completes for me I have tried everything I can think of to do this.

      jsulmJ Offline
      jsulmJ Offline
      jsulm
      Lifetime Qt Champion
      wrote on last edited by
      #2

      @AI_Messiah Your description is not clear. Do you mean the auto-completion feature in QtCreator does not work for you?

      https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      1
      • A Offline
        A Offline
        AI_Messiah
        wrote on last edited by
        #3

        What I mean is that when I try do do something like

        QString mystr = ui->textbox1->text;
        

        I know it wouldn't look like this but I am using it as an example. It will not work.

        JonBJ jsulmJ 2 Replies Last reply
        0
        • A AI_Messiah

          What I mean is that when I try do do something like

          QString mystr = ui->textbox1->text;
          

          I know it wouldn't look like this but I am using it as an example. It will not work.

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

          @AI_Messiah said in Accessing form element's properties:

          It will not work.

          In what way? It won't autocomplete in editor? It won't compile? It doesn't behave as expected at runtime?

          That should "work" if you do it from the right file. Note that you will want the parentheses as per

          QString mystr = ui->textbox1->text();
          
          1 Reply Last reply
          0
          • A AI_Messiah

            What I mean is that when I try do do something like

            QString mystr = ui->textbox1->text;
            

            I know it wouldn't look like this but I am using it as an example. It will not work.

            jsulmJ Offline
            jsulmJ Offline
            jsulm
            Lifetime Qt Champion
            wrote on last edited by
            #5

            @AI_Messiah said in Accessing form element's properties:

            QString mystr = ui->textbox1->text;

            Of course it will not work as it's invalid syntax.
            It has to be:

            QString mystr = ui->textbox1->text();
            

            Or do I misunderstand the problem?

            https://forum.qt.io/topic/113070/qt-code-of-conduct

            1 Reply Last reply
            0
            • A Offline
              A Offline
              AI_Messiah
              wrote on last edited by
              #6

              What I found is that you have to include all of the controls that you want in your application with the first edit of the ui file

              mrjjM 1 Reply Last reply
              0
              • A AI_Messiah

                What I found is that you have to include all of the controls that you want in your application with the first edit of the ui file

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

                @AI_Messiah

                Hi
                We are not sure what you think is not working so good.

                If you mean Auto completion or something else.

                • What I found is that you have to include all of the controls that you want in your application with the first edit of the ui file

                This suggests you mean that when you place a widget on the form, then switch
                back to code and try
                to do
                ui->newname->

                and it won't guess on "newname" ?

                if yes, you can press Ctrl+Alt+B

                alt text

                that will build the file and then ui->newname is surely
                available.

                1 Reply Last reply
                0
                • A Offline
                  A Offline
                  AI_Messiah
                  wrote on last edited by
                  #8

                  What I mean is the first time you edit the form this is when you have to include all of your controls. Otherwise they will not show up when you try to reference them.

                  jsulmJ 1 Reply Last reply
                  0
                  • A AI_Messiah

                    What I mean is the first time you edit the form this is when you have to include all of your controls. Otherwise they will not show up when you try to reference them.

                    jsulmJ Offline
                    jsulmJ Offline
                    jsulm
                    Lifetime Qt Champion
                    wrote on last edited by
                    #9

                    @AI_Messiah After editing the ui file in designer you should rebuild your project, so the uic compiler generates ui code, then autocomplition should work.

                    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