gpt4 book ai didi

c++ - QComboBox 子类中的断点不起作用

转载 作者:行者123 更新时间:2023-11-30 03:10:41 26 4
gpt4 key购买 nike

我已将 QComboBox 子类化以根据特殊需要对其进行自定义。该子类用于在 QtDesigner 的 ui 文件中提升 QComboBoxes。一切正常,除了当我在插槽中放置断点时,程序不会在断点处停止。但是我知道它是从它生成的结果中调用的。我检查了我程序中的其他插槽,它们可以很好地处理断点。进行清理和重建都没有解决它。是什么原因造成的,我能做些什么吗?有问题的插槽是子类中唯一的一个,称为“do_indexChanged()”。您可以在下面的类头文件的第 37 行找到槽,在类源文件的第 10 行找到信号槽连接。
类标题:

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

最佳答案

这很可能是因为该文件未使用调试信息编译,因此调试器无法在那里中断。尝试将您的应用链接到 libQtGui*.so/.dylib/.dll 的调试版本

关于c++ - QComboBox 子类中的断点不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2953992/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com