Results 1 to 3 of 3

Thread: Overriding a widget with another in a layout

  1. #1
    Join Date
    Dec 2009
    Posts
    52
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Overriding a widget with another in a layout

    Hi,

    I have a main layout which contains a QListWidget and a QWidget that depends on the selected row in the QListWidget.
    I store the list of QWidget in a local array, 1 QWidget for each row in the list.
    I connected the currentTextChanged signal of QListWidget to my custom slot, where I remove the widgets whose rows are not selected from the layout, then add the widget whose row has just been selected using ->currentRow() from QListWidget and removeWidget and addWidget from QLayout

    Initally, widgets seem to change but they'd appear on top of each other (messing up the display). I added setAutoFillBackground(true) for those widgets, but now on changing selection in the list, nothing appears to happen, though debugging shows the correct widget is removed and the right one added.

    rds,

  2. #2
    Join Date
    Apr 2010
    Posts
    769
    Thanks
    1
    Thanked 94 Times in 86 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default Re: Overriding a widget with another in a layout

    Try using a QStackedWidget

  3. #3
    Join Date
    Dec 2009
    Posts
    52
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Overriding a widget with another in a layout

    thanks very much,
    worls like a charm,

Similar Threads

  1. Is it possible to find a widget's Layout which add it?
    By HiJack in forum Qt Programming
    Replies: 7
    Last Post: 30th April 2010, 09:01
  2. How to change a widget to other widget in layout?
    By Kevin Hoang in forum Qt Programming
    Replies: 2
    Last Post: 20th March 2010, 10:55
  3. Widget layout in GridLayout
    By Dato0011 in forum Qt Programming
    Replies: 8
    Last Post: 7th December 2009, 09:26
  4. changing layout of a widget
    By mikro in forum Qt Programming
    Replies: 10
    Last Post: 4th August 2009, 20:21
  5. Stacked Layout. & Widget.
    By csvivek in forum Qt Programming
    Replies: 1
    Last Post: 13th May 2008, 08:56

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.