Results 1 to 3 of 3

Thread: The problem about how to delete a widget in the QSplitter

  1. #1
    Join Date
    Jul 2013
    Posts
    9
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows

    Default The problem about how to delete a widget in the QSplitter

    Hi everyone,
    I have faced with a problem about the QSplitter.I have create a class inherited from QSplitter.I want this class can add or delete a widget dynamically.I know how to add a widget.But I don't know how to delete a wiget in the QSplitter.Do someone know how to do it?
    Please help.
    Thanks in advance.

  2. #2
    Join Date
    Mar 2011
    Location
    Hyderabad, India
    Posts
    1,882
    Thanks
    3
    Thanked 452 Times in 435 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows
    Wiki edits
    15

    Default Re: The problem about how to delete a widget in the QSplitter

    If you have handle of the widget just do a regular delete
    Qt Code:
    1. delete widget;
    To copy to clipboard, switch view to plain text mode 

    If widget's handle is not available, then you can get the widget using QSplitter::index()
    Qt Code:
    1. QSplitter * splitter;
    2. int index;
    3. ...
    4. QWidget * widget = splitter->widget(index);
    5. delete widget;
    To copy to clipboard, switch view to plain text mode 
    When you know how to do it then you may do it wrong.
    When you don't know how to do it then it is not that you may do it wrong but you may not do it right.

  3. #3
    Join Date
    Jul 2013
    Posts
    9
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows

    Default Re: The problem about how to delete a widget in the QSplitter

    Thank you very much.The method you say works right to meet my need.

Similar Threads

  1. problem with QSplitter
    By tangtao_xp in forum Newbie
    Replies: 9
    Last Post: 27th June 2013, 03:16
  2. Problem with QSplitter
    By kistmaximum in forum Qt Programming
    Replies: 2
    Last Post: 10th June 2012, 01:28
  3. Widget proportions in QSplitter
    By godi in forum Qt Programming
    Replies: 4
    Last Post: 30th September 2011, 08:59
  4. Delete content widget in layout
    By Hogwarts in forum Qt Programming
    Replies: 1
    Last Post: 17th December 2010, 16:59
  5. QSplitter ignores some widget methods
    By lotek in forum Qt Programming
    Replies: 0
    Last Post: 13th October 2010, 20:29

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.