2010-06-01 55 views
1

我已將子類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(); 
} 

回答

1

我發現了這個問題。我需要做的就是將函數定義放在.cpp文件中。

2

這很可能是由於這樣的事實,該文件不與調試信息compilled,因此調試器將無法打破那裏。嘗試將您的應用程序鏈接到一個調試版本的libQtGui * .so/.dylib/.dll

+0

您也可以使用qmake和項目文件指定調試版本。看一看qmake文檔中的例子。 – TerryP 2010-06-01 23:36:41

+0

我已經在調試模式。反正班上其他地方的斷點工作。 – 2010-06-02 00:11:42

+0

問題是,每個文件都必須用調試信息進行編譯。爲您的項目設置調試模式意味着您的項目文件使用調試信息進行編譯,但它可能無法保證由您的項目鏈接的庫也使用調試信息構建。 – Gianni 2010-06-02 00:58:29