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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T07:16:54+00:00 2026-05-29T07:16:54+00:00

I am developing a gui proram using Qt 4.7.4 (64 bit). I have tried

  • 0

I am developing a gui proram using Qt 4.7.4 (64 bit). I have tried to isolate the problem as follows:

I have a window: class PreferencesWindow : public QMainWindow and in another class I initialize and show it as

QSharedPointer<PreferencesWindow> pPreferencesWindow = QSharedPointer<PreferencesWindow>(new PreferencesWindow());
pPreferencesWindow->show();

it is all good, then I close the window either by pressing ESC or clicking the x button on the window. And then I call

QApplication::quit();

to terminate the whole program. It terminates but gives a segmentation fault just before terminating.

The question here is why it terminates cleanly when I use regular pointer instead of QSharedPointer and how to use QSharedPointer properly in this case?

  • 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-29T07:16:54+00:00Added an answer on May 29, 2026 at 7:16 am

    I suspect the problem is that when you close the window, the data structure pointed to by pPreferencesWindow is deleted without the QSharedPointer‘s knowledge. When the QSharedPointer itself is later destroyed, it double-deletes the window, and you get the segfault.

    Basically, as with all shared pointer implementations, either everybody plays, or nobody does. Since the Qt internals will never know you’re using a smart pointer to manage the window, you can’t use one. This is a blessing in disguise, however; it means that Qt itself takes possession of the pointer and agrees to manage it for you, so you don’t need a smart pointer after all!

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

Sidebar

Related Questions

I'm developing a GUI in C++ using dev-c++. I have an edit control like
XulRunner/Gecko seems to be really interesting for developing GUI-intensive applications (by using widely used
I'm developing Swing application, and everything works fine usually. But I have an GUI
I have been studying swing for developing gui applications since a few days. The
I am developing a GUI application in Qt, and I have some difficulties embedding
I am developing a GUI application in C# using the design mode in VS2008.
i am developing a GUI , using java Swing library .I want to add
I'm developing a WinForms application in C#. I have limited experience in GUI programming,
i am developing a GUI using Java Swing. but i got stuck here. Is
I am developing desktop GUI application using java swing. And I want to show

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.