SIGSEGV when using more than one pointer in a c++ class [SOLVED]

  • Hi everyone, this is my first time working with Qt in a project, and I'm facing a problem that I'm not really sure how to solve, in fact I'm not really sure if it is Qt or C++ related.

    I'm trying to get all the "QPushButtons" and "QSpinBox" I've already placed in "Designer" into an array of pointers, so I can change quickly the properties of all of them together. For doing so I have declared two pointers to pointers inside the class like this:

    (NO RUN)
    QPushButton **arrayBotonesColores = NULL;
    QSpinBox **arraySpinGrosores = NULL;

    When using this I'm getting a SIGSEGV every time I launch the application, even before I get anything on screen. I have commented all the code that uses those pointers and I keep getting the SIGSEGV.

    Here is the thing I can't really understand, if I comment one of the two lines, no matter which, the program runs as expected.

    //QPushButton **arrayBotonesColores = NULL;
    QSpinBox **arraySpinGrosores = NULL;

    QPushButton **arrayBotonesColores = NULL;
    //QSpinBox **arraySpinGrosores = NULL;

    ¿Does anybody know what is the problem here?
    Any kind of help will be very grateful

    PD: Here are the full header / source files, if needed

  • Hi brusapa,

    I can´t reproduce the SIGSEGV you get. I have created a new Dialog and pasted your code. The code runs with both pointers without any problems on my machine.
    I had to comment out some code in animTodo, because I don´t have your ui resource file. Have you tried to run qmake, clean an then rebuild?
    Maybe there is some old object file causing the error.
    Can you provide some Information about the platform and Compiler you are using?

  • @sneubert and rebuilding the project solves the problem... I can't believe I've spent three hours on this and I haven't tried that...
    Thank you very much for your help!

  • you are not the first one and i guess this wont happen to you any more

Log in to reply

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.