Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8769505
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T17:21:47+00:00 2026-06-13T17:21:47+00:00

What I want is to completely remove a widget (purge it, delete it, etc…),

  • 0

What I want is to completely remove a widget (purge it, delete it, etc…), but it’s in a gridlayout, so even when calling removeWidget, it still keeps a pointer, so python doesn’t want to remove the object. Here is the (stripped) code:

def addRow(self, row):
    self.entries.insert(row, QtGui.QLineEdit())
    self.gridlayout.addWidget(self.entries[row], row, 0)
...
def remRow(self, row):
    self.gridlayout.removeWidget(self.entries[row])
    del(self.entries[row])
...
(in another function)
foo.addRow(0)
foo.remRow(0)

It removes the widget from the gridlayout, but it doesn’t remove it completely, so it actually gets packed beneath(?) the layout, and the widget is apparently bigger than the layout (not sure though, as I cannot see the end).

So again, is there any way to completely remove a widget that was inside a QGridLayout?

Thanks in advance!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T17:21:48+00:00Added an answer on June 13, 2026 at 5:21 pm

    Layouts re-parent the widgets to the containers. So even if you remove it from the layout, container widget is still the parent, so that widget is not removed. You should call .deleteLater() to tell Qt to get rid of that widget (effectively clearing all references for the widget so that Python can purge it):

    def remRow(self, row):
        self.gridlayout.removeWidget(self.entries[row])
        self.entries[row].deleteLater()
        del self.entries[row]
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I hava installed oracle-jdk,so want to remove openjdk completely to ensure every java-based apps
I want to completely remove Python 2.7 from my Mac OS X 10.6.4. I
function removeNewsItem(id,idStamp,obj){ $('#whiteCover')show(); $('#contentOfBox').html= ('Are you sure you want ot completely remove this news
I want to completely remove error list from visual studio 2008, not disable it
I want to remove viewstate from page completely without using MVC pattern. I am
I am using WordPress, and I want to remove profile menu-option completely Any one
I'm trying to free up my apps memory and want to completely remove loadingImageView
I created a Visual Studio 2010 project that I want to remove completely and
I making an application with my own keyboard and I want to completely DISABLE
With reXml using Ruby, I have a particular element and I want to completely

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.