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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T05:25:08+00:00 2026-06-04T05:25:08+00:00

After googling around I found out that segmentation faults are given when the program

  • 0

After googling around I found out that segmentation faults are given when the program is pointed to use memory that it doesn’t have access to.

I’ve recently started experiencing these errors after I tried making a custom button class that would enclose, in its clicked() signal, an integer.

Here’s the custom button class:

.h:

#include <QtGui>

#ifndef CUSTOMBUTTON_H
#define CUSTOMBUTTON_H

class CustomButton : public QPushButton        //This simple class allows us to map arguments in the Widget's cicked() signal.
{                                              //In the project, it's used in the delete-edit buttons so the program knows which part of the Movie/Theater/Screening list we're referring to
 Q_OBJECT

public:
 CustomButton(QString name,int num, QWidget *parent = 0);

signals:
 void clicked(int pos);

private:
 QSignalMapper *signalMapper;
};

#endif // CUSTOMBUTTON_H

.cpp:

#include "custombutton.h"

CustomButton::CustomButton(QString name,int num = 0, QWidget *parent) //Our constructor
    : QPushButton(name,parent)
{   //Our button's now created and shown, through the superconstructor. Let's take care of its clicked() signal.

    signalMapper = new QSignalMapper(this);

    connect(this, SIGNAL(clicked()), signalMapper, SLOT(map()));
    signalMapper->setMapping(this, num);


    connect(signalMapper, SIGNAL(mapped(int)),this, SIGNAL(clicked(int)));

}

And then in my main code I do:

CustomButton *edit_button = new CustomButton("Edit",i,0);
edit_button->setFixedWidth(30);
connect(edit_button,SIGNAL(clicked(int)),this,SLOT(edit_movie(int))); //When the user decides to edit a movie, we set the class'es working_with var to the position of the film in the MovieList and we set the screen to the appropriate one.


CustomButton *del_button = new CustomButton("Delete",i,0);            //We pass i as an argument to the button, so it can relate to the movie it's set next to.
del_button->setFixedWidth(45);
connect(del_button,SIGNAL(clicked(int)),this,SLOT(del_movie(int)));

Where i is the number I want it to have in the signal.

Thing is, thorugh the debugger it doesn’t give me a segfault if I press the Delete button. It all happens in the edit one.

As I’m still pretty confused and in a situation where I don’t even know WHAT to ask about, if you need anything else from me please say so and I will provide.

Here’s the backtrace, which I know not how to read:

0 QHash<QObject*, QString>::findNode qhash.h 884 0×69e98594
1 QHash<QObject*, QString>::contains qhash.h 874 0×69e98568
2 QSignalMapper::map qsignalmapper.cpp 267 0×69debe0c
3 QSignalMapper::map qsignalmapper.cpp 257 0×69debda2
4 QSignalMapper::qt_static_metacall moc_qsignalmapper.cpp 64 0×69debfce
5 QMetaObject::activate qobject.cpp 3547 0×69de9baf
6 QAbstractButton::clicked moc_qabstractbutton.cpp 220 0×10cb4b8
7 QAbstractButtonPrivate::emitClicked qabstractbutton.cpp 548 0xe2e517
8 QAbstractButtonPrivate::click qabstractbutton.cpp 541 0xe2e495
9 QAbstractButton::mouseReleaseEvent qabstractbutton.cpp 1123 0xe2f941
10 QWidget::event qwidget.cpp 8362 0xae63de
11 QAbstractButton::event qabstractbutton.cpp 1082 0xe2f7cc
12 QPushButton::event qpushbutton.cpp 683 0xecfeba
13 QApplicationPrivate::notify_helper qapplication.cpp 4554 0xa9c020
14 QApplication::notify qapplication.cpp 4097 0xa9a26a
15 QCoreApplication::notifyInternal qcoreapplication.cpp 876 0×69dd3b76
16 QCoreApplication::sendSpontaneousEvent qcoreapplication.h 234 0×113137e
17 QApplicationPrivate::sendMouseEvent qapplication.cpp 3163 0xa98ad6
18 QETWidget::translateMouseEvent qapplication_win.cpp 3363 0xb03171
19 QtWndProc qapplication_win.cpp 1696 0xafdf66
20 USER32!IsDialogMessageW C:\Windows\syswow64\user32.dll 0 0×76726238
21 USER32!RegisterSystemThread C:\Windows\syswow64\user32.dll 0 0×767278b0
22 ?? 0 0×30000
23 USER32!AllowForegroundActivation C:\Windows\syswow64\user32.dll 0 0×767268ea
24 qt_is_translatable_mouse_event qapplication_win.cpp 1463 0xafd465
25 USER32!GetMessageExtraInfo C:\Windows\syswow64\user32.dll 0 0×76727d31
26 ?? 0 

Any heads up as to what might be causing the problem? As I said, the segfault only occurs if I run the program through the Debugger and when I press the “Edit” button, of the CustomButton class. When I normally build&run, the program works 9/10 times. Sometimes, clicking the edit button results in a crash. This erratic behaviour is what caused me to look for help here.

As when I click the button I’m taken to a new screen, I’m suspecting that the problem might lie in the decstructor? Does a blank destructor correctly deconstruct elements of objects of the CustomButton class, seeing as the actual object is passed to the base class constructor? Maybe I’ve got a leak there?

  • 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-04T05:25:12+00:00Added an answer on June 4, 2026 at 5:25 am

    Unless knowing where you create the objects, it’s hard to tell why there is a segfault in QSignalMapper. The pointer to your signal mapper might be invalid at some point in time, so there might be an unwanted deletion.

    In some cases, a complete rebuild of your application might be helpful. Also re-running qmake. Just should be on your checklist when you can’t explain why there is a segfault …;)

    There is an alternative to QSignalMapper: keep your signal clicked(int) and implement a private slot:

    private slots:
        this_clicked() {
            emit clicked(num);
        }
    

    Then put in the constructor:

    connect(this, SIGNAL(clicked()), SLOT(this_clicked()));
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to create schema.sql instead of schema.rb. After googling around I found that
Update III: After googling around I've found that this is not an uncommon problem.
After some googling around I have found not a lot on the question I
I have no idea how to write Bash and after googling around for a
There are many similar questions, but nothing that answers this specifically after googling around
From googling around, I found that using while loops or using variables is discouraged.
I think this is a pretty basic question, but after Googling around I can't
After googling i came to know that Index seek is better than scan. How
After googling, browsing SO and reading , there doesn't seem to be a Rails-style
Anyone know what this error means? after googling I found a bunch of sites

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.