Results 1 to 7 of 7

Thread: breakpoint inside QComboBox subclass not working

  1. #1
    Join Date
    Dec 2009
    Posts
    29
    Thanks
    2
    Thanked 3 Times in 3 Posts

    Default breakpoint inside QComboBox subclass not working

    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:

    Qt Code:
    1. #ifndef WVQCOMBOBOX_H
    2. #define WVQCOMBOBOX_H
    3.  
    4. #include <QWidget>
    5. #include <QObject>
    6. #include <QComboBox>
    7. #include <QVariant>
    8.  
    9.  
    10.  
    11. class wvQComboBox : public QComboBox
    12. {
    13. Q_OBJECT
    14. //Q_PROPERTY(bool writeEnable READ writeEnable WRITE setWriteEnable)
    15. public:
    16. explicit wvQComboBox(QWidget *parent = 0);
    17. bool writeEnable() {
    18. return this->property("writeEnable").toBool();
    19. }
    20. void setWriteEnable(const bool & writeEnable){
    21. this->setProperty("writeEnable",writeEnable);
    22. }
    23.  
    24. bool newValReady() {
    25. return this->property("newValReady").toBool();
    26. }
    27. void setNewValReady(const bool & newValReady){
    28. this->setProperty("newValReady",newValReady);
    29. }
    30. QString getNewVal();
    31. int getNewValIndex();
    32.  
    33.  
    34.  
    35. int oldVal; //comboBox Index before user edit began
    36. private slots:
    37. void do_indexChanged(){
    38. this->setWriteEnable(true);
    39. if(oldVal!=currentIndex()){
    40. this->setNewValReady(true);
    41. oldVal=currentIndex();
    42. }
    43. }
    44.  
    45. protected:
    46. void focusInEvent ( QFocusEvent * event );
    47. //void focusOutEvent ( QFocusEvent * event );//dont need because of currentIndexChanged(int)
    48. };
    49.  
    50. #endif // WVQCOMBOBOX_H
    To copy to clipboard, switch view to plain text mode 


    CLASS SOURCE
    Qt Code:
    1. #include "wvqcombobox.h"
    2.  
    3. wvQComboBox::wvQComboBox(QWidget *parent) :
    4. QComboBox(parent)
    5. {
    6. this->setWriteEnable(true);
    7. this->setNewValReady(false);
    8. oldVal=this->currentIndex();
    9.  
    10. connect(this,SIGNAL(currentIndexChanged(int)),this,SLOT(do_indexChanged()));
    11. }
    12.  
    13. void wvQComboBox::focusInEvent ( QFocusEvent * event ) {
    14. this->setWriteEnable(false);
    15. oldVal=this->currentIndex();
    16. }
    17.  
    18.  
    19. QString wvQComboBox::getNewVal(){
    20. setNewValReady(false);
    21. return this->currentText();
    22. }
    23.  
    24. int wvQComboBox::getNewValIndex(){
    25. setNewValReady(false);
    26. return this->currentIndex();
    27. }
    To copy to clipboard, switch view to plain text mode 

  2. #2
    Join Date
    Nov 2009
    Location
    Sacramento, CA
    Posts
    24
    Thanked 1 Time in 1 Post
    Qt products
    Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: breakpoint inside QComboBox subclass not working

    Are you sure the connect returns true? If I remember correctly, signals and slots have to have the same parameter lists.

  3. #3
    Join Date
    Dec 2009
    Posts
    29
    Thanks
    2
    Thanked 3 Times in 3 Posts

    Default Re: breakpoint inside QComboBox subclass not working

    Quote Originally Posted by steno View Post
    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.
    Last edited by yodasoda; 2nd June 2010 at 02:12.

  4. #4
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: breakpoint inside QComboBox subclass not working

    Which line in the slot are you marking with the breakpoint?

  5. #5
    Join Date
    Dec 2009
    Posts
    29
    Thanks
    2
    Thanked 3 Times in 3 Posts

    Default Re: breakpoint inside QComboBox subclass not working

    Quote Originally Posted by ChrisW67 View Post
    Which line in the slot are you marking with the breakpoint?
    I actually marked them all.

  6. #6
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: breakpoint inside QComboBox subclass not working

    Long shot here... have you tried moving the do_indexChanged() implementation in to the cpp file rather than the header?

  7. The following user says thank you to ChrisW67 for this useful post:

    yodasoda (3rd June 2010)

  8. #7
    Join Date
    Dec 2009
    Posts
    29
    Thanks
    2
    Thanked 3 Times in 3 Posts

    Default Re: breakpoint inside QComboBox subclass not working

    Quote Originally Posted by ChrisW67 View Post
    Long shot here... have you tried moving the do_indexChanged() implementation in to the cpp file rather than the header?
    it worked thanks!

Similar Threads

  1. QComboBox::insertSeparator(int index) is not working
    By osiris81 in forum Qt Programming
    Replies: 2
    Last Post: 14th July 2011, 19:43
  2. Replies: 1
    Last Post: 18th December 2009, 21:57
  3. Focus frame inside QComboBox list
    By alpinista in forum Qt Programming
    Replies: 2
    Last Post: 13th November 2009, 15:30
  4. Replies: 1
    Last Post: 13th June 2008, 19:58
  5. QComboBox inside QTableWidget
    By campana in forum Qt Programming
    Replies: 7
    Last Post: 20th March 2006, 18:22

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.