Results 1 to 3 of 3

Thread: how to insert one widget between another two widgets ina a list of widgets)

  1. #1
    Join Date
    Jul 2010
    Posts
    17
    Thanks
    8
    Qt products
    Qt4
    Platforms
    Windows

    Default how to insert one widget between another two widgets ina a list of widgets)

    hi, i have a problem that i can't solve for the moment.
    I have a list where i load a list of messages, each message is displayed in a widget panel.

    i'm trying to perform go up & down actions with a up & down buttons and i don´t know how to remove a widget and insert it again one position before.

    could anyone help me??

    here there are some code:

    Qt Code:
    1. QWidget *scrollWidget = ui.scrollTx;
    2. QLayout *layout = scrollWidget->layout ();
    3.  
    4. //this code is to remove panels that they already are in the list
    5. QLayoutItem *child = 0;
    6. while ((child = layout->takeAt(0)) != 0)
    7. {
    8. QWidget *widget = child->widget();
    9. if (widget) widget->deleteLater();
    10. delete child;
    11. }
    12.  
    13. // with this code i create the panels
    14. for (it = m_cListaTx.begin (); it != m_cListaTx.end ();)
    15. {
    16. CArincMsgData *msg = *it;
    17. if (msg)
    18. {
    19. PanelTx *panel = new PanelTx (msg, *this, layout->widget());
    20. layout->addWidget (panel);
    21.  
    22. }
    23. it++;
    24. }
    25.  
    26. ((QVBoxLayout *)layout)->addStretch ();
    To copy to clipboard, switch view to plain text mode 

    but afterthat in other function i need to insert panels between some of them,
    and i just have found this method to insert widgets: layout->addWidget (panel);

    can i perform what i want?

    thanks anyway

  2. #2
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Wiki edits
    5

    Default Re: how to insert one widget between another two widgets ina a list of widgets)

    see QBoxLayout::insertWidget() and you might reconsider using QListWidget with custom widgets. It should be easier and for a short list its ok.

  3. The following user says thank you to Lykurg for this useful post:

    pakine (25th August 2010)

  4. #3
    Join Date
    Jul 2010
    Posts
    17
    Thanks
    8
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: how to insert one widget between another two widgets ina a list of widgets)

    ok i got it, thank you very much

Similar Threads

  1. Populating a QtableWidget using a list of custom widgets
    By gerocampo in forum Qt Programming
    Replies: 1
    Last Post: 4th August 2010, 11:28
  2. How to build a list of custom widgets
    By curreli in forum Newbie
    Replies: 6
    Last Post: 28th July 2010, 13:55
  3. Replies: 5
    Last Post: 19th April 2010, 00:31
  4. List of Widgets
    By linuxdev in forum Qt Tools
    Replies: 3
    Last Post: 30th April 2009, 15:24
  5. QTableWidget : insert multiple widgets in one cell..
    By halberdier83 in forum Qt Programming
    Replies: 3
    Last Post: 26th November 2007, 17:15

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.