Results 1 to 2 of 2

Thread: Create Row dynamically in QListWidget

  1. #1
    Join Date
    Nov 2009
    Posts
    9
    Qt products
    Qt4
    Platforms
    Windows

    Lightbulb Create Row dynamically in QListWidget

    Hi,

    I want to create a custome widget. Please help by giving some idea.
    My intention is to make a Listwidget which shows some Information and when clicking particulat row it have to show the details coresponding to that row by creating a new area(Row or text edit) immediately below the selected row and pull the other rows below the selected row to down after the created new area.
    In attachment when I click row Nancy (consider it as row) her details is coming below the selected row. Please help on this
    Attached Images Attached Images

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

    Default Re: Create Row dynamically in QListWidget

    You could do this by using QTableWidget, considering the attachment you posted, it has 8 columns and multiple rows, so here is how you can do this

    - Create QTableWidget with 8 columns, and how ever row you want to
    - Then set the row selection behavior (tableWidget->setSelectionBehavior(QAbstractItemView::SelectRow s); )
    - When user selects any item of given row (you could used void itemClicked(QTableWidgetItem * item) signal)
    - Create a new item with your required details, and insert it right below the selected item, i.e. the next row
    - For the new detailed item created, set the column span to 8, such that it will stretch the whole table width (tableWidget->setSpan(new_row, 0, 1, 8); )

    You now can see what you wanted, just take care of removing and deleting the new detailed item when use selects an another item, next time.

Similar Threads

  1. dynamically create QLabels
    By jeffmetal in forum Newbie
    Replies: 5
    Last Post: 19th June 2011, 18:24
  2. Replies: 1
    Last Post: 29th November 2010, 17:22
  3. How to add items dynamically to QListWidget?
    By mind_freak in forum Qt Programming
    Replies: 1
    Last Post: 26th November 2010, 20:54
  4. Dynamically create SVG with QWebElement
    By yawar in forum Qt Programming
    Replies: 0
    Last Post: 11th April 2010, 03:53
  5. dynamically create folders with QT
    By eleanor in forum Newbie
    Replies: 3
    Last Post: 13th March 2007, 11:40

Tags for this Thread

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
  •  
Qt is a trademark of The Qt Company.