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?
Forum Updated to NodeBB v4.3 + New Features

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 573 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 5 Aug 2020, 12:19 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.

    J 1 Reply Last reply 5 Aug 2020, 12:23
    0
    • N NageswaRao
      5 Aug 2020, 12:19

      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.

      J Offline
      J Offline
      jsulm
      Lifetime Qt Champion
      wrote on 5 Aug 2020, 12:23 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 5 Aug 2020, 12:25 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

        J 1 Reply Last reply 5 Aug 2020, 12:26
        0
        • N NageswaRao
          5 Aug 2020, 12:25

          @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

          J Offline
          J Offline
          jsulm
          Lifetime Qt Champion
          wrote on 5 Aug 2020, 12:26 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 5 Aug 2020, 12:30
          1
          • J jsulm
            5 Aug 2020, 12:26

            @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 5 Aug 2020, 12:30 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.

            J 1 Reply Last reply 5 Aug 2020, 12:31
            0
            • N NageswaRao
              5 Aug 2020, 12:30

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

              J Offline
              J Offline
              jsulm
              Lifetime Qt Champion
              wrote on 5 Aug 2020, 12:31 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 5 Aug 2020, 12:33 last edited by NageswaRao 8 May 2020, 12:34
                #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

                J 1 Reply Last reply 5 Aug 2020, 12:55
                0
                • N NageswaRao
                  5 Aug 2020, 12:33

                  @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

                  J Offline
                  J Offline
                  jsulm
                  Lifetime Qt Champion
                  wrote on 5 Aug 2020, 12:55 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

                  6/8

                  5 Aug 2020, 12:31

                  • Login

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