delete gridlayout and its widget



  • please sad to me how can i delete my gridlayout


  • Lifetime Qt Champion

    Hi,

    Do you mean the Qt Quick type ?


  • Moderators

    @Asid
    something like this?

    void clearLayout( QLayout* layout )
    {
        QLayoutItem* item = Q_NULLPTR;
        while( (item = layout->takeAt(0)) )
        {
            if (item->layout())
            {
                clearLayout( item->layout() );
                delete item->layout();
            }
            else if ( item->widget() )
                delete item->widget();
            else if( item->spacerItem() )
                delete item->spacerItem();
    
            delete item;
        }
    }
    
    QWidget* widgetWithGridLayout = ...;
    QGridLayout* gridLayout = ....;
    clearLayout( gridLayout );
    delete gridLayout;
    delete widgetWithGridLayout;
    

Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.