Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Call for Presentations - Qt World Summit

    Unsolved How to update label position which is added on mainwindhow.ui using QT programatically?

    General and Desktop
    2
    8
    168
    Loading More Posts
    • 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.
    • N
      NageswaRao last edited by

      Hi Team, I have added one label called 'lable_new' on the "exampletwo.ui". This label is coming as expected when I run the QT application. But when I want to change the label position using programmatically using below the line in "exampletwo.php".

      ui->lable_new->setGeometry(300, 500, 250, 250);

      This newly, the updated position is coming and disappearing, and the label position is coming in old position instead of taking the above-updated position. Am I doing something wrong? Thanks in advance.

      jsulm 1 Reply Last reply Reply Quote 0
      • jsulm
        jsulm Lifetime Qt Champion @NageswaRao last edited by

        @NageswaRao said in How to update label position which is added on mainwindhow.ui using QT programatically?:

        using below the line in "exampletwo.php"

        What is this file? Looks like PHP.
        Can you show actual code?
        Is this label in a layout?

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

        1 Reply Last reply Reply Quote 1
        • N
          NageswaRao last edited by

          @jsulm said in How to update label position which is added on mainwindhow.ui using QT programatically?:

          Is this label in a layout?

          Yes. This label in a layout only

          jsulm 1 Reply Last reply Reply Quote 0
          • jsulm
            jsulm Lifetime Qt Champion @NageswaRao last edited by

            @NageswaRao said in How to update label position which is added on mainwindhow.ui using QT programatically?:

            This label in a layout only

            In this case the layout handles the position and size of the label. Why do you want to use setGeometry on a widget which is in a layout?

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

            N 1 Reply Last reply Reply Quote 1
            • N
              NageswaRao @jsulm last edited by

              @jsulm When I move the mouse position, the label position also should move along with the mouse pointer. so I'm updating the label position.

              jsulm 1 Reply Last reply Reply Quote 0
              • jsulm
                jsulm Lifetime Qt Champion @NageswaRao last edited by

                @NageswaRao Then remove the label from layout

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

                1 Reply Last reply Reply Quote 1
                • N
                  NageswaRao last edited by NageswaRao

                  @jsulm you mean I need to add a label from the CPP code right? Like below link.

                  https://stackoverflow.com/questions/39348635/qt-add-label-to-certain-position

                  jsulm 1 Reply Last reply Reply Quote 0
                  • jsulm
                    jsulm Lifetime Qt Champion @NageswaRao last edited by

                    @NageswaRao said in How to update label position which is added on mainwindhow.ui using QT programatically?:

                    you mean I need to add a label from the CPP code right?

                    No, you just should not add it to any layouts

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

                    1 Reply Last reply Reply Quote 2
                    • First post
                      Last post