PDA

View Full Version : breakpoint inside QComboBox subclass not working



yodasoda
2nd June 2010, 00:04
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



CLASS SOURCE


#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();
}

steno
2nd June 2010, 01:29
Are you sure the connect returns true? If I remember correctly, signals and slots have to have the same parameter lists.

yodasoda
2nd June 2010, 02:06
Are you sure the connect returns true? If I remember correctly, signals and slots have to have the same parameter lists.

yes I have tried with the same signature and it gives the same result. Also I am 100% sure the connect returns true.

ChrisW67
2nd June 2010, 08:57
Which line in the slot are you marking with the breakpoint?

yodasoda
2nd June 2010, 18:37
Which line in the slot are you marking with the breakpoint?

I actually marked them all.

ChrisW67
3rd June 2010, 10:29
Long shot here... have you tried moving the do_indexChanged() implementation in to the cpp file rather than the header?

yodasoda
4th June 2010, 18:02
Long shot here... have you tried moving the do_indexChanged() implementation in to the cpp file rather than the header?

it worked thanks!