Hello!
I have a small problem with connecting the custom signal and the custom slot(Object::connect: No such signal)
Here is the code, what I have:
datedialog.h:
	
	- #ifndef DATEDIALOG_H 
- #define DATEDIALOG_H 
-   
- #include <QDialog> 
-   
- { 
-     Q_OBJECT 
-   
- public: 
- signals: 
-     void-  SendText (const QString &- text )- ; 
 
-   
- private: 
-     void Initialization(); 
-     void PlacingElements(); 
-   
- private slots: 
-     void-  EnableOKButton (const QString &- text )- ; 
 
-     void GetDateToLine(); 
-     void BeforeShowMsg(); 
-     void-  ShowMessageBox (const QString &- text )- ; 
 
-   
- private: 
-   
- }; 
-   
- #endif // DATEDIALOG_H 
        #ifndef DATEDIALOG_H
#define DATEDIALOG_H
#include <QDialog>
class QPushButton;
class QLineEdit;
class QCalendarWidget;
class DateDialog:public QDialog
{
    Q_OBJECT
public:
    DateDialog(QWidget *parent = 0);
signals:
    void SendText(const QString &text);
private:
    void Initialization();
    void PlacingElements();
private slots:
    void EnableOKButton(const QString &text);
    void GetDateToLine();
    void BeforeShowMsg();
    void ShowMessageBox(const QString &text);
private:
QCalendarWidget *calendar;
QLineEdit *line;
QPushButton *OkButton;
};
#endif // DATEDIALOG_H
To copy to clipboard, switch view to plain text mode 
  
datedialog.cpp
	
	- #include "datedialog.h" 
- #include <QHBoxLayout> 
- #include <QCalendarWidget> 
- #include <QLineEdit> 
- #include <QPushButton> 
- #include <QIcon> 
- #include <QString> 
- #include <QMessageBox> 
-   
- { 
-     Initialization(); 
- } 
-   
- void DateDialog::Initialization() 
- { 
-     line->setFocus(); 
-     OkButton->setDefault(true); 
-     OkButton->setEnabled(false); 
-     connect(this->calendar, SIGNAL(selectionChanged()), 
-             this, SLOT(GetDateToLine())); 
-     connect(- this -- >line,  SIGNAL(- textChanged (const QString &))- , 
 
-             this- ,  SLOT(- EnableOKButton (const QString &)))- ; 
 
-     connect(this->OkButton, SIGNAL(clicked()), 
-             this, SLOT(BeforeShowMsg())); 
-    connect(this- ,  SIGNAL(- SendText (- cosnt  QString &))- , 
 
-             this- ,  SLOT(- ShowMessageBox (const QString &)))- ; 
 
-     PlacingElements(); 
- } 
-   
- void DateDialog::PlacingElements() 
- { 
-     leftTop->addWidget(this->line); 
-     leftDown->addWidget(OkButton); 
-   
-     left->addLayout(leftTop); 
-     left->addStretch(); 
-     left->addLayout(leftDown); 
-   
-     right->addWidget(this->calendar); 
-   
-     main->addLayout(left); 
-     main->addLayout(right); 
-   
-     this->setLayout(main); 
-     this -- >setWindowTitle (QObject::tr("Date"))- ; 
-   
-     QString-  FilePath  = "E:\\linux-penguin-computing.jpg"- ; 
 
-     this -- >setWindowIcon (QIcon(- FilePath ))- ; 
-     this->setFixedSize(sizeHint().width(), sizeHint().height()); 
- } 
-   
- void-  DateDialog ::EnableOKButton(const QString &- text )
 
- { 
-  this->OkButton->setEnabled(!text.isEmpty()); 
-  OkButton->setEnabled(true); 
- } 
-   
- void DateDialog::GetDateToLine() 
- { 
-  this->line->setText(calendar->selectedDate().toString("dd/MM/yyyy dddd")); 
- } 
-   
- void-  DateDialog ::ShowMessageBox(const QString &- text )
 
- { 
-  msg.setText(text); 
-  msg. setWindowTitle(QObject::tr("Information before closing"))- ; 
-  msg.exec(); 
-  this->close(); 
- } 
-   
- void DateDialog::BeforeShowMsg() 
- { 
-     if(!line->text().isEmpty()) 
-     { 
-      emit SendText(line->text()); 
-     } 
- } 
        #include "datedialog.h"
#include <QHBoxLayout>
#include <QCalendarWidget>
#include <QLineEdit>
#include <QPushButton>
#include <QIcon>
#include <QString>
#include <QMessageBox>
DateDialog::DateDialog(QWidget *parent):QDialog(parent)
{
    Initialization();
}
void DateDialog::Initialization()
{
    calendar = new QCalendarWidget();
    line = new QLineEdit();
    line->setFocus();
    OkButton = new QPushButton(QObject::tr("Press me!"));
    OkButton->setDefault(true);
    OkButton->setEnabled(false);
    connect(this->calendar, SIGNAL(selectionChanged()),
            this, SLOT(GetDateToLine()));
    connect(this->line, SIGNAL(textChanged(const QString &)),
            this, SLOT(EnableOKButton(const QString &)));
    connect(this->OkButton, SIGNAL(clicked()),
            this, SLOT(BeforeShowMsg()));
   connect(this, SIGNAL(SendText(cosnt QString &)),
            this, SLOT(ShowMessageBox(const QString &)));
    PlacingElements();
}
void DateDialog::PlacingElements()
{
    QHBoxLayout *leftTop = new QHBoxLayout;
    leftTop->addWidget(this->line);
    QHBoxLayout *leftDown = new QHBoxLayout;
    leftDown->addWidget(OkButton);
    QVBoxLayout *left = new QVBoxLayout;
    left->addLayout(leftTop);
    left->addStretch();
    left->addLayout(leftDown);
    QVBoxLayout *right = new QVBoxLayout;
    right->addWidget(this->calendar);
    QHBoxLayout *main = new QHBoxLayout;
    main->addLayout(left);
    main->addLayout(right);
    this->setLayout(main);
    this->setWindowTitle(QObject::tr("Date"));
    QString FilePath = "E:\\linux-penguin-computing.jpg";
    this->setWindowIcon(QIcon(FilePath));
    this->setFixedSize(sizeHint().width(), sizeHint().height());
}
void DateDialog::EnableOKButton(const QString &text)
{
 this->OkButton->setEnabled(!text.isEmpty());
 OkButton->setEnabled(true);
}
void DateDialog::GetDateToLine()
{
 this->line->setText(calendar->selectedDate().toString("dd/MM/yyyy dddd"));
}
void DateDialog::ShowMessageBox(const QString &text)
{
 QMessageBox msg;
 msg.setText(text);
 msg.setWindowTitle(QObject::tr("Information before closing"));
 msg.setIcon(QMessageBox::Warning);
 msg.exec();
 this->close();
}
void DateDialog::BeforeShowMsg()
{
    if(!line->text().isEmpty())
    {
     emit SendText(line->text());
    }
}
To copy to clipboard, switch view to plain text mode 
  
main.cpp:
	
	- #include <QtGui/QApplication> 
- #include "datedialog.h" 
-   
- int main(int argc, char *argv[]) 
- { 
-   
-     DateDialog date; 
-     date.exec(); 
-   
-     return app.exec(); 
- } 
        #include <QtGui/QApplication>
#include "datedialog.h"
int main(int argc, char *argv[])
{
    QApplication app(argc, argv);
    DateDialog date;
    date.exec();
    return app.exec();
}
To copy to clipboard, switch view to plain text mode 
  
The first question that I have is: why?
And the second one is: How it can be rectified?
Thank you beforehand for answers.
				
			
Bookmarks