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 7408135
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T05:51:30+00:00 2026-05-29T05:51:30+00:00

I was using Qt to build a basic GUI for an application and I

  • 0

I was using Qt to build a basic GUI for an application and I have a few questions..
So I created the GUI, it works fine and I thought I would check something..

for(int i=0; i < 100000; i++)
{
    menu = new QMenu(this);
    act = new QAction("About", menu);
    menu->addAction(act);
    connect(act, SIGNAL(triggered()), this, SLOT(slotHelpAbout()));
    menuBar()->addMenu(menu)->setText("Help");
}
menuBar()->clear();

I use the QMenuBar of the QMainWindow class and fill it up with QMenu which are also filled up with QAction for wich I connect the triggered signal to a few slots.. This works fine but when I call clear it should delete the menu/action items contained by QMenuBar.. I am checking in task manager and the memory usage is still huge..
Even after:

    QList<QAction*> lst = menuBar()->actions();

    for(int i=0;i < lst.length(); i++)
    {
        delete lst.at(i);
    }

Shouldn’t all memory used by the QMenus and QActions be freed ?

  • 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-05-29T05:51:31+00:00Added an answer on May 29, 2026 at 5:51 am

    QMenuBar::clear will do nothing for you since, as pointed out by @Dave Mateer, it only removes actions from the QMenuBar and doesn’t delete them.

    Also, deleting the list of actions from the QMenuBar will not cause each QMenu itself to be deleted.

    Each QMenu that you have is parented to this which is presumably your QMainWindow. They will only be deleted when you delete the QMainWindow and not it’s menu bar. You can change your code so that you parent each QMenu to the QMenuBar so that deleting the menu bar deletes the menus (and their actions). Alternatively you can keep hold of pointers to each individual menu and delete them manually.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an application which i build using gcc on linux host for ARM
I managed to build a basic IFrame application, using the Graph API. I wanted
I would like to do some basic charting in F# using build in features
I have build a game using canvas and Javascript, and I would like to
I have a basic C++ applicatin build using g++ and -framework ... when I
I have a form build with zend using a viewscript. I thought that by
I would like to build two versions of my Android application using an Apache
I have build a basic .NET server-client infrastructure using TcpListener and SocketClient. It is
I want to build an API service using Django. A basic workflow goes like
Why is using '*' to build a view bad ? Suppose that you have

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.