我已将子类QComboBox自定义为特殊需要。该子类用于在来自QtDesigner的ui文件中提升QComboBoxes。除了当我在一个插槽中放置一个断点时,所有程序都可以工作,程序不会停在断点处。但我知道它是从它产生的结果中调用的。我检查了我的程序中的其他插槽,并且它们可以很好地处理断点。做一个干净的和重建所有没有解决它。有什么可能导致这种情况,我能做些什么呢?所讨论的槽是子类中唯一的槽,称为“do_indexChanged()”。您可以在类头文件的第37行找到插槽,并在类源文件的第10行找到信号插槽连接。
类的头:QComboBox子类中的断点不工作
#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();
}
您也可以使用qmake和项目文件指定调试版本。看一看qmake文档中的例子。 – TerryP 2010-06-01 23:36:41
我已经在调试模式。反正班上其他地方的断点工作。 – 2010-06-02 00:11:42
问题是,每个文件都必须用调试信息进行编译。为您的项目设置调试模式意味着您的项目文件使用调试信息进行编译,但它可能无法保证由您的项目链接的库也使用调试信息构建。 – Gianni 2010-06-02 00:58:29