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 update label position which is added on mainwindhow.ui using QT programatically?
QtWS25 Last Chance

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

Scheduled Pinned Locked Moved Unsolved General and Desktop
8 Posts 2 Posters 554 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.
  • N Offline
    N Offline
    NageswaRao
    wrote on last edited by
    #1

    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.

    jsulmJ 1 Reply Last reply
    0
    • N NageswaRao

      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.

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

      @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
      1
      • N Offline
        N Offline
        NageswaRao
        wrote on last edited by
        #3

        @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

        jsulmJ 1 Reply Last reply
        0
        • N NageswaRao

          @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

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

          @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
          1
          • jsulmJ jsulm

            @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?

            N Offline
            N Offline
            NageswaRao
            wrote on last edited by
            #5

            @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.

            jsulmJ 1 Reply Last reply
            0
            • N NageswaRao

              @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.

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

              @NageswaRao Then remove the label from layout

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

              1 Reply Last reply
              1
              • N Offline
                N Offline
                NageswaRao
                wrote on last edited by NageswaRao
                #7

                @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

                jsulmJ 1 Reply Last reply
                0
                • N 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

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

                  @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
                  2

                  • Login

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