Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. When removing from layout the widget is not fully removed

When removing from layout the widget is not fully removed

Scheduled Pinned Locked Moved General and Desktop
2 Posts 2 Posters 782 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • appollosputnikA Offline
    appollosputnikA Offline
    appollosputnik
    Banned
    wrote on last edited by
    #1

    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.

    [code]
    QWidget *cent = new QWidget(this);
    cent->resize(1000,800);
    setCentralWidget(cent);
    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);
    text->resize(200,100);
    list[row][col] = text;
    layout->addWidget(list[row][col],row,col);
    }
    }
    cent->setLayout(layout);
    layout->removeWidget(list[1][1]);
    [/code]
    please help

    1 Reply Last reply
    0
    • T Offline
      T Offline
      TheFox
      wrote on last edited by
      #2

      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];
      widget->deleteLater();@

      Or if you only want to hide it:
      @widget->hide();@

      1 Reply Last reply
      0

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved