views:

44

answers:

2

I have subclassed QComboBox to customize it for special needs. The subclass is used to promote QComboBoxes in a ui file from QtDesigner. Everything works except that when I put a break point in a slot, the program does not stop at the breakpoint. I do however know that it is being called from the result it generates. I checked other slots in my program and they work fine with breakpoints. Doing a clean and rebuild all did not fix it. What could be causing this and is there anything I can do about it? The slot in question is the only one in the subclass and is called "do_indexChanged()". You can find the slot on line 37 of the class header below and the signal-slot connection on line 10 of the class source file.
CLASS HEADER:

#ifndef WVQCOMBOBOX_H
#define WVQCOMBOBOX_H

#include <QWidget>
#include <QObject>
#include <QComboBox>
#include <QVariant>



class wvQComboBox : public QComboBox
{
Q_OBJECT
//Q_PROPERTY(bool writeEnable READ writeEnable WRITE setWriteEnable)
public:
    explicit wvQComboBox(QWidget *parent = 0);
    bool writeEnable() {
        return this->property("writeEnable").toBool();
    }
    void setWriteEnable(const bool & writeEnable){
        this->setProperty("writeEnable",writeEnable);
    }

    bool newValReady() {
        return this->property("newValReady").toBool();
    }
    void setNewValReady(const bool & newValReady){
        this->setProperty("newValReady",newValReady);
    }
    QString getNewVal();
    int getNewValIndex();



    int oldVal;  //comboBox Index before user edit began
private slots:
    void do_indexChanged(){
        this->setWriteEnable(true);
        if(oldVal!=currentIndex()){
            this->setNewValReady(true);
            oldVal=currentIndex();
        }
    }

protected:
    void focusInEvent ( QFocusEvent * event );
    //void focusOutEvent ( QFocusEvent * event );//dont need because of currentIndexChanged(int)
};

#endif // WVQCOMBOBOX_H


#include "wvqcombobox.h"

wvQComboBox::wvQComboBox(QWidget *parent) :
    QComboBox(parent)
{
    this->setWriteEnable(true);
    this->setNewValReady(false);
    oldVal=this->currentIndex();

    connect(this,SIGNAL(currentIndexChanged(int)),this,SLOT(do_indexChanged()));
}

void wvQComboBox::focusInEvent ( QFocusEvent * event ) {
    this->setWriteEnable(false);
    oldVal=this->currentIndex();
}


QString  wvQComboBox::getNewVal(){
    setNewValReady(false);
    return this->currentText();
}

int wvQComboBox::getNewValIndex(){
    setNewValReady(false);
    return this->currentIndex();
}
+2  A: 

This is most likely due to the fact that that file was not compilled with debug info, therefore the debugger won't be able to break there. Try linking your app to a debug version of libQtGui*.so/.dylib/.dll

Gianni
You can also specify debug builds using qmake and the project file. Take a look see in the qmake documentation for examples.
TerryP
I am already in debug mode. Anyways breakpoints anywhere else in the class work.
yan bellavance
The point is, EVERY file has to be compiled with debug info. Setting debug mode for your project means that your project's files are compiled with debug info, but it might not guarantee that libraries linked by your project were also built with debug info.
Gianni
ok I will give it a try. The other day I had the same situation but for all slots. And the reason was that I had specified a different directory to put my moc files in with the following directive in my .pro file: MOC_DIR = ./MocDir I presume this made GDB not see the slots and that it is the same reason why this slot's breakpoints are not working.
yan bellavance
A: 

I found the problem. All I needed to do was to put the function definition in the .cpp file.

yan bellavance