Object::connect: No such slot QGroupBox::lcs_slot(bool)
Well, I’ve searched this many times in Google, and still I can’t solve it, so I ask for some help. I desigener it for using qt designer
I’ve seen the documentation, and I think this is the way to declare a custom slot:
My .h file
- //=================extensiondlg.h=====================
- #ifndef EXTENSIONDLG_H
- #define EXTENSIONDLG_H
- #include <QDialog>
- #include "ui_extensionDlg.h"
- {
- Q_OBJECT
- public:
- public slots:
- void lcs_slot(bool);
- };
- #endif
my .cpp file
- //=====================extension.cpp=====================
- #include <QtGui>
- #include "extensionDlg.h"
- {
- setupUi(this);
- this->extensionGroupBox->hide();
- }
- void ExtensionDlg::lcs_slot(bool lcs)
- {
- if (lcs)
- {
- this->extensionGroupBox->hide();
- }
- else
- {
- this->extensionGroupBox->hide();
- }
- }
- //=======================main.cpp===================
- #include "extensionDlg.h"
- #include <QApplication>
- int main(int argc, char *argv[])
- {
- ExtensionDlg *dlg = new ExtensionDlg;
- dlg->show();
- return app.exec();
- }
- //======================================================
ui_extensionDlg.h as follow..
Thank you for any answers or help.
5 replies
- //==================ui_extensionDlg.h======================
- /********************************************************************************
- ** Form generated from reading UI file 'extensionDlgDesigner.ui'
- **
- ** Created: Sun Apr 8 23:49:42 2012
- ** by: Qt User Interface Compiler version 4.7.0
- **
- ** WARNING! All changes made in this file will be lost when recompiling UI file!
- ********************************************************************************/
- #ifndef UI_EXTENSIONDLGDESIGNER_H
- #define UI_EXTENSIONDLGDESIGNER_H
- #include <QtCore/QVariant>
- #include <QtGui/QAction>
- #include <QtGui/QApplication>
- #include <QtGui/QButtonGroup>
- #include <QtGui/QComboBox>
- #include <QtGui/QDialog>
- #include <QtGui/QFormLayout>
- #include <QtGui/QGroupBox>
- #include <QtGui/QHBoxLayout>
- #include <QtGui/QHeaderView>
- #include <QtGui/QLabel>
- #include <QtGui/QLineEdit>
- #include <QtGui/QPushButton>
- #include <QtGui/QSpacerItem>
- #include <QtGui/QVBoxLayout>
- QT_BEGIN_NAMESPACE
- class Ui_Dialog
- {
- public:
- {
- if (Dialog->objectName().isEmpty())
- Dialog->resize(284, 302);
- verticalLayout->addLayout(formLayout);
- okButton->setDefault(true);
- horizontalLayout->addWidget(okButton);
- detailButton->setDefault(true);
- horizontalLayout->addWidget(detailButton);
- verticalLayout->addLayout(horizontalLayout);
- verticalLayout_2->addWidget(basicGroupBox);
- verticalLayout_2->addItem(verticalSpacer);
- verticalLayout_2->addWidget(extensionGroupBox);
- retranslateUi(Dialog);
- } // setupUi
- {
- sexComboBox->clear();
- );
- extensionGroupBox->setTitle(QApplication::translate("Dialog", "Extension", 0, QApplication::UnicodeUTF8));
- sexComboBox_2->clear();
- );
- } // retranslateUi
- };
- namespace Ui {
- class Dialog: public Ui_Dialog {};
- } // namespace Ui
- QT_END_NAMESPACE
- #endif // UI_EXTENSIONDLGDESIGNER_H
On line 117, you can see that:
Then, on line 162, you make the connection:
So, you are trying to connect to the lcs_slot in a QGroupBox, but the slot really exists in a your ExtensionDlg class. That’s where you go wrong.
Did you by any chance manually modify the ui_extensionDlg.h file? If so: don’t.
Never alter the generated ui_*.h files. From the top of my head, there is even a warning at the top of this file to tell you so. The file will be overwritten the next time you build the application…
You can solve this by making the connection in the extensionDlg.cpp file, right after your setupUi() call.
You must log in to post a reply. Not a member yet? Register here!


