Qt World Summit: Register Today!

When removing from layout the widget is not fully removed

  • Banned

    when i am removing widget from QGridLayout, the widget is removed from the corresponding row and column but it is still there on the screen. How to remove it completely.

    QWidget *cent = new QWidget(this);
    QTextEdit *list[3][3];
    QGridLayout *layout = new QGridLayout(cent);
    for(int row=0; row<3; row++)
    for(int col=0; col<3; col++)
    QTextEdit *text = new QTextEdit(cent);
    list[row][col] = text;
    please help

  • bq. Removes the widget widget from the layout. After this call, it is the caller's responsibility to give the widget a reasonable geometry or to put the widget back into a layout.
    Note: The ownership of widget remains the same as when it was added

    If you want the widget to be deleted, you need to delete it yourself:
    @ QTextEdit * widget = list[1][1];

    Or if you only want to hide it:

Log in to reply