Results 1 to 20 of 23

Thread: my slots don't appear in the signal slot editor

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Sep 2009
    Location
    UK
    Posts
    2,447
    Thanks
    6
    Thanked 348 Times in 333 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: my slots don't appear in the signal slot editor

    slots will be grayed out if the slot is incompatible with the signal. For example, a slot expecting an int will not accept a signal that emits a char *

    All connect statements generated by designer will be present in the header file and executed when setupui is called.

  2. #2
    Join Date
    Aug 2008
    Posts
    38
    Thanks
    19
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: my slots don't appear in the signal slot editor

    OK but why do these slots show up as choices in the Qt C++ signal slot tab below???

    and with "my" connect statement tha works, how do I fix the other 3

    for subtract, mutiply and divide

    connect(ui.pushButtonAdd,SIGNAL(clicked()),this,SL OT(addClicked()));

    QAbstratButton has
    Signals

    *
    void clicked ( bool checked = false ) argument optional
    *
    void pressed ()
    *
    void released ()
    *
    void toggled ( bool checked )

    *
    1 signal inherited from QWidget
    *
    1 signal inherited from QObject

    My slots are all void void
    Last edited by landonmkelsey; 2nd December 2009 at 17:30.

  3. #3
    Join Date
    Sep 2009
    Location
    UK
    Posts
    2,447
    Thanks
    6
    Thanked 348 Times in 333 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: my slots don't appear in the signal slot editor

    Your slots shouldn't be all void void. If there are no parameters, the parameter list should be empty, otherwise the slots will be grayed out in designer.

    If you create a slot in designer and name it "foo()", then it will allow you to assign the clicked() event to that slot using the "Edit signals/slots" editor (ie, you drag a line from the button to whatever)

    If you are still having problems, post your project.

  4. #4
    Join Date
    Aug 2008
    Posts
    38
    Thanks
    19
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: my slots don't appear in the signal slot editor

    I have tar'ed and gzip'ed the workspace (Eclipse) for the project attached

    If you don't have Eclipse with Qt designer plugin, I can export the files and "retar"

  5. #5
    Join Date
    Sep 2009
    Location
    UK
    Posts
    2,447
    Thanks
    6
    Thanked 348 Times in 333 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: my slots don't appear in the signal slot editor

    You seem to have forgotten to attach the project.

    Secondly, have you tried to open the .ui file in QtDesigner itself rather than the Eclipse plugin to make sure it isn't a bug in the plugin?

  6. #6
    Join Date
    Aug 2008
    Posts
    38
    Thanks
    19
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default

    I exported necessary files via tar and gzip.

    I removed *.o and executable

    -rw-rw-r--. 1 qt4 qt4 1225203 2009-12-02 19:04 trycalc.tar.gz
    too big to attach.

    Do you have an email I could send it to?

    I will try using the designer alone to look at what is going on!

    where does one say thanks!

    this time I clicked on "edit" and was allowed to enter the 4 methods/slots.

    However when I dragged the red line out of a pushbutton, the choices were grayed out.

    This looks like a bug or missing feature.

    Who wants to limit slots to base class slots?

    Again, the C++ signal slot editor tab near the bottom shows and allows selection of user slots.

    Hitting F4 or the editor that pops up from the icon at the top doesn't allow
    Last edited by wysota; 3rd December 2009 at 10:42.

  7. #7
    Join Date
    Sep 2009
    Location
    Tashkent, Uzbekistan
    Posts
    107
    Thanks
    1
    Thanked 4 Times in 4 Posts
    Qt products
    Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: my slots don't appear in the signal slot editor

    may be this:
    Qt Code:
    1. clicked(bool c = false)
    To copy to clipboard, switch view to plain text mode 
    ? void is actually not equal to default argument.

  8. #8
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,018 Times in 4,794 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: my slots don't appear in the signal slot editor

    Please edit your posts if you have anything to add instead of replying to yourself.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  9. #9
    Join Date
    Aug 2008
    Posts
    38
    Thanks
    19
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: my slots don't appear in the signal slot editor

    wysota:
    just curious...are you a Nokia (formerly Trolltech) employee??

    Tanuli-no:
    thanks! clicked(bool c = false) occurred to me even though it is really unnecessary.

    Come to think of it,
    he whole original parameter spec should really be used anyway!

    Assuming that is correct (I think it is) why are the user slots appearing at the bottom dialog (tab) and not at the top dialog (F4/icon)?
    The following compiled and ran but with warning:
    Object::connect: No such signal QPushButton::clicked(bool c) in trycalc.cpp:7
    Object::connect: (sender name: 'pushButtonAdd')
    Object::connect: (receiver name: 'trycalcClass')


    Qt Code:
    1. #ifndef TRYCALC_H
    2. #define TRYCALC_H
    3.  
    4. #include <QtGui/QWidget>
    5. #include "ui_trycalc.h"
    6.  
    7. class trycalc : public QWidget
    8. {
    9. Q_OBJECT
    10.  
    11. public:
    12. trycalc(QWidget *parent = 0);
    13. ~trycalc();
    14.  
    15. private:
    16. Ui::trycalcClass ui;
    17. public slots:
    18. void addClicked(bool c = false);
    19. void subClicked(bool c = false);
    20. void mulClicked(bool c = false);
    21. void divClicked(bool c = false);
    22.  
    23. };
    24.  
    25. #endif // TRYCALC_H
    26.  
    27.  
    28. #include "trycalc.h"
    29. #include <QMessageBox>
    30. trycalc::trycalc(QWidget *parent)
    31. : QWidget(parent)
    32. {
    33. ui.setupUi(this);
    34. connect(ui.pushButtonAdd,SIGNAL(clicked(bool c)),this,SLOT(addClicked(bool c;
    35. }
    36.  
    37. trycalc::~trycalc()
    38. {
    39.  
    40. }
    41. //
    42. void trycalc::addClicked(bool c)
    43. {
    44.  
    45. QString qstring1 = ui.lineEdit->text();
    46. QString qstring2 = ui.lineEdit_2->text();
    47.  
    48. bool ok1 = true;
    49. bool ok2 = true;
    50. float f1 = qstring1.toFloat(&ok1);
    51. float f2 = qstring2.toFloat(&ok2);
    52. if( qstring1.length() == 0
    53. || qstring2.length() == 0
    54. || !ok1
    55. || !ok2)
    56. {
    57. QMessageBox mb("Adder",
    58. "missing or bad entry",
    59. QMessageBox::Warning,
    60. QMessageBox::NoButton ,
    61. QMessageBox::NoButton);
    62. mb.exec();
    63. ui.lineEdit->clear();
    64. ui.lineEdit_2->clear();
    65. ui.lineEdit_3->clear();
    66. return;
    67. }
    68. float f3 = f1 + f2;
    69. QString qstring3;
    70. qstring3.setNum(f3);
    71. ui.lineEdit_3->setText(qstring3);
    72. }
    73. void trycalc::subClicked(bool c)
    74. {
    75. QString qstring1 = ui.lineEdit->text();
    76. QString qstring2 = ui.lineEdit_2->text();
    77.  
    78. bool ok1 = true;
    79. bool ok2 = true;
    80. float f1 = qstring1.toFloat(&ok1);
    81. float f2 = qstring2.toFloat(&ok2);
    82. if( qstring1.length() == 0
    83. || qstring2.length() == 0
    84. || !ok1
    85. || !ok2)
    86. {
    87. QMessageBox mb("Adder",
    88. "missing or bad entry",
    89. QMessageBox::Warning,
    90. QMessageBox::NoButton ,
    91. QMessageBox::NoButton);
    92. mb.exec();
    93. ui.lineEdit->clear();
    94. ui.lineEdit_2->clear();
    95. ui.lineEdit_3->clear();
    96. return;
    97. }
    98. float f3 = f1 - f2;
    99. QString qstring3;
    100. qstring3.setNum(f3);
    101. ui.lineEdit_3->setText(qstring3);
    102. }
    103. void trycalc::mulClicked(bool c)
    104. {
    105.  
    106. QString qstring1 = ui.lineEdit->text();
    107. QString qstring2 = ui.lineEdit_2->text();
    108.  
    109. bool ok1 = true;
    110. bool ok2 = true;
    111. float f1 = qstring1.toFloat(&ok1);
    112. float f2 = qstring2.toFloat(&ok2);
    113. if( qstring1.length() == 0
    114. || qstring2.length() == 0
    115. || !ok1
    116. || !ok2)
    117. {
    118. QMessageBox mb("Adder",
    119. "missing or bad entry",
    120. QMessageBox::Warning,
    121. QMessageBox::NoButton ,
    122. QMessageBox::NoButton);
    123. mb.exec();
    124. ui.lineEdit->clear();
    125. ui.lineEdit_2->clear();
    126. ui.lineEdit_3->clear();
    127. return;
    128. }
    129. float f3 = f1 * f2;
    130. QString qstring3;
    131. qstring3.setNum(f3);
    132. ui.lineEdit_3->setText(qstring3);
    133. }
    134. void trycalc::divClicked(bool c)
    135. {
    136.  
    137. QString qstring1 = ui.lineEdit->text();
    138. QString qstring2 = ui.lineEdit_2->text();
    139.  
    140. bool ok1 = true;
    141. bool ok2 = true;
    142. float f1 = qstring1.toFloat(&ok1);
    143. float f2 = qstring2.toFloat(&ok2);
    144. if( qstring1.length() == 0
    145. || qstring2.length() == 0
    146. || !ok1
    147. || !ok2
    148. || f2==0.)
    149. {
    150. QMessageBox mb("Adder",
    151. "missing or bad entry",
    152. QMessageBox::Warning,
    153. QMessageBox::NoButton ,
    154. QMessageBox::NoButton);
    155. mb.exec();
    156. ui.lineEdit->clear();
    157. ui.lineEdit_2->clear();
    158. ui.lineEdit_3->clear();
    159. return;
    160. }
    161. float f3;
    162. if (f2 != 0.) f3 = f1 / f2;
    163. QString qstring3;
    164. qstring3.setNum(f3);
    165. ui.lineEdit_3->setText(qstring3);
    166. }
    To copy to clipboard, switch view to plain text mode 
    Last edited by landonmkelsey; 3rd December 2009 at 16:04. Reason: add on not posting a new post as directed

  10. #10
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,018 Times in 4,794 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: my slots don't appear in the signal slot editor

    Quote Originally Posted by landonmkelsey View Post
    wysota:
    just curious...are you a Nokia (formerly Trolltech) employee??
    No, I'm not.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  11. #11
    Join Date
    Sep 2009
    Location
    UK
    Posts
    2,447
    Thanks
    6
    Thanked 348 Times in 333 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: my slots don't appear in the signal slot editor

    What is this?

    Qt Code:
    1. void addClicked(bool c = false);
    2. void subClicked(bool c = false);
    3. void mulClicked(bool c = false);
    4. void divClicked(bool c = false);
    To copy to clipboard, switch view to plain text mode 

    If you don't care about the state, it should be:

    Qt Code:
    1. void addClicked();
    2. void subClicked();
    3. void mulClicked();
    4. void divClicked();
    To copy to clipboard, switch view to plain text mode 

    As mentioned previously.

  12. #12
    Join Date
    Aug 2008
    Posts
    38
    Thanks
    19
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: my slots don't appear in the signal slot editor

    somebody recommended a fix and I was giving it a shot

    Your recommendation describes my original code.

    My original code compiled and ran without warning/error.

  13. #13
    Join Date
    Sep 2009
    Location
    UK
    Posts
    2,447
    Thanks
    6
    Thanked 348 Times in 333 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: my slots don't appear in the signal slot editor

    Attach your .ui file

Similar Threads

  1. Queuing problem with signal and slots
    By montylee in forum Qt Programming
    Replies: 4
    Last Post: 20th November 2009, 06:11
  2. pthread instead QThread
    By brevleq in forum Qt Programming
    Replies: 8
    Last Post: 23rd December 2008, 07:16
  3. Connection of custon signals/slots
    By brevleq in forum Qt Programming
    Replies: 2
    Last Post: 23rd December 2008, 07:04
  4. Signal & Slot editor
    By Ishark in forum Qt Tools
    Replies: 4
    Last Post: 28th May 2008, 15:20
  5. Signal and slots
    By villy in forum Qt Programming
    Replies: 1
    Last Post: 12th January 2007, 10:10

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
  •  
Qt is a trademark of The Qt Company.