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. Label text overlap another label text when both the labels at the same position
QtWS25 Last Chance

Label text overlap another label text when both the labels at the same position

Scheduled Pinned Locked Moved General and Desktop
5 Posts 4 Posters 2.5k 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.
  • Y Offline
    Y Offline
    yhodage
    wrote on last edited by
    #1

    Hi ,

    i have created the QLabel on the container(QFrame) at a position. after that i have created the another container(QFrame) with the Qlabel at the same location.
    I found that the label text of first container overlap with label on second container while showing application.

    i tried to set the setAutoFillBackground(true) but did not work.

    1 Reply Last reply
    0
    • L Offline
      L Offline
      LightFractal
      wrote on last edited by
      #2

      You should provide some minimal working code for us to better understand the problem.

      1 Reply Last reply
      0
      • dheerendraD Offline
        dheerendraD Offline
        dheerendra
        Qt Champions 2022
        wrote on last edited by
        #3

        From your description it looks to me that you are not using the layout for positioning. Use layout and it will not overlap. Also if you give sample code we can give you quick example as well.

        Dheerendra
        @Community Service
        Certified Qt Specialist
        http://www.pthinks.com

        1 Reply Last reply
        0
        • Y Offline
          Y Offline
          yhodage
          wrote on last edited by
          #4

          LabelWidget (QWidget* parent, const char* name)
          : QLabel (name, parent)
          {setAutoFillBackground(true);}

          here parent is QFrame i.e. container.
          above constructor is called for twice to create the two labels at the same location.

          1 Reply Last reply
          0
          • raven-worxR Offline
            raven-worxR Offline
            raven-worx
            Moderators
            wrote on last edited by
            #5

            [quote author="yhodage" date="1389618743"]
            i have created the QLabel on the container(QFrame) at a position. after that i have created the another container(QFrame) with the Qlabel at the same location.
            I found that the label text of first container overlap with label on second container while showing application.

            i tried to set the setAutoFillBackground(true) but did not work.[/quote]

            you should use QStackedWidget for such a purpose.
            But if you want to do the positioning manually you need to set the background:

            With stylesheets:
            @
            myLabel->setStylesheet("QLabel { background: gray; }"
            @

            With QPalette:
            @
            QPalette palette = myLabel->palette();
            palette.setBrush(QPalette::Window, QPalette().brush(QPalette::Window));
            myLabel->setAutofillBackground(true);
            myLabel->setPalette(palette);
            @

            --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
            If you have a question please use the forum so others can benefit from the solution in the future

            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