Important: Please read the Qt Code of Conduct -

How to delete widgets from Qvboxlayout

  • Hi friends,

              i am facing the one issue,,how to delete all widget from qvboxlayout in Qt,,After deleteing the widget i need to add some widget in the same Qvboxlayout,,now i delete the widget from Qvboxlayout,,and after that i add the new widget means Qvboxlayout take more spaces between the two widgets,, In below i added the code for deleting the widget from layout

    @QLayoutItem* item;
    while ( ( item = rightui->listLayout->takeAt( 0 ) ) != NULL )
    if (item->widget()) {
    qDebug() << "item widget: " << item->widget();
    delete item->widget();
    delete item;
    Please Give me a good solution for this,,,Thanks

Log in to reply