Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. Problem removing widget from a layout

Problem removing widget from a layout

Scheduled Pinned Locked Moved Mobile and Embedded
7 Posts 6 Posters 4.6k 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.
  • M Offline
    M Offline
    mmesarina
    wrote on last edited by
    #1

    Hi,

    this seems like something that should just work, but it doesn't.
    I have a layout and I want to remove a widget for which I have a pointer to and it is just not doing it.
    I am using removeWidget(*widget) , like this:
    @

    extLayout->removeWidget(treeWidget);
    @

    Do I need to do something extra?

    thanks

    -malena

    1 Reply Last reply
    0
    • W Offline
      W Offline
      wladek
      wrote on last edited by
      #2

      Hi mmesarina,

      Is you interest in deleting the widget? From the docs of "QLayout":http://doc.qt.nokia.com/4.7-snapshot/qlayout.html#removeWidget seems that the widget still exists, and it is your responsibility to put in in another layout. Try adding it to a different layout, or if you don't need it anymore, just delete the pointer to this QWidget.

      Hope this helps,
      wladek

      1 Reply Last reply
      0
      • G Offline
        G Offline
        giesbert
        wrote on last edited by
        #3

        What do you expect to happen and what happens?
        The widget will not be deleted and not be invisible.

        Nokia Certified Qt Specialist.
        Programming Is Like Sex: One mistake and you have to support it for the rest of your life. (Michael Sinz)

        1 Reply Last reply
        0
        • J Offline
          J Offline
          jorj
          wrote on last edited by
          #4

          you could try setting the widgets parent to 0, or as wladek says, if you do not need it, delete it.

          1 Reply Last reply
          0
          • G Offline
            G Offline
            giesbert
            wrote on last edited by
            #5

            setting the parent to 0 is not the best idea, because then you have a new top level window, and perhaps, that's not the expected behavior.

            Nokia Certified Qt Specialist.
            Programming Is Like Sex: One mistake and you have to support it for the rest of your life. (Michael Sinz)

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

              Or, if you do need it again (later on), simply hide the widget instead of removing it from the layout.

              1 Reply Last reply
              0
              • Z Offline
                Z Offline
                ZapB
                wrote on last edited by
                #7

                As others have said, the code you posted is sufficient to remove the widget from the layout. However it is not sufficient to hide it or delete it or reparent it or add it to another layout. And so the widget will still be visible. What are you trying to achieve?

                Nokia Certified Qt Specialist
                Interested in hearing about Qt related work

                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