Fatla
2nd June 2008, 19:44
I'm creating my first app with my own slot .
Everything goes sooo fine till now . However when I want to create my own slot , nothing
is happened (i.e. slot didn't work !! )
The purpose of my App : when the user press a button , an empty .txt file 'll be created .
I'm working under MS Win XP , & I've tried to run it over Linux to find out the problem . I've such that output :
Object::connect: No such slot QDialog::Custom()
Object::connect: (sender name: 'pushButton')
Object::connect: (receiver name: 'Form')
Though , I've add such this slot "Custom" @ QTDesign .
I've got .exe BUT the slot never responds ( i.e. Createing the file )
I've added a little piece of code @ the header file which was generated , is that true !!
I'm using :
- qt-win-opensource-4.4.0
- qmake to build the project
-MinGw
N.B. : I've created the slot , according to what I've understand from QT Assistant
So , What' the problem @ My Code :
/************************************************** ******************************
** Form generated from reading ui file 'Test.ui'
**
** Created: Mon Jun 2 06:29:48 2008
** by: Qt User Interface Compiler version 4.4.0
**
** WARNING! All changes made in this file will be lost when recompiling ui file!
************************************************** ******************************/
#ifndef UI_TEST_H
#define UI_TEST_H
#include <QtCore/QVariant>
#include <QtGui/QAction>
#include <QtGui/QApplication>
#include <QtGui/QButtonGroup>
#include <QtGui/QLineEdit>
#include <QtGui/QPushButton>
#include <QtGui/QWidget>
// **************** My Own Code *********************
#include <stdio.h>
// **************** My Own Code *********************
QT_BEGIN_NAMESPACE
class Ui_Form
{
public:
QPushButton *pushButton;
QLineEdit *lineEdit;
void setupUi(QWidget *Form)
{
if (Form->objectName().isEmpty())
Form->setObjectName(QString::fromUtf8("Form"));
Form->resize(475, 393);
pushButton = new QPushButton(Form);
pushButton->setObjectName(QString::fromUtf8("pushButton"));
pushButton->setGeometry(QRect(170, 190, 75, 24));
lineEdit = new QLineEdit(Form);
lineEdit->setObjectName(QString::fromUtf8("lineEdit"));
lineEdit->setGeometry(QRect(160, 90, 113, 20));
retranslateUi(Form);
QObject::connect(pushButton, SIGNAL(pressed()), Form, SLOT(Custom()));
QMetaObject::connectSlotsByName(Form);
} // setupUi
void retranslateUi(QWidget *Form)
{
Form->setWindowTitle(QApplication::translate("Form", "Form", 0, QApplication::UnicodeUTF8));
pushButton->setText(QApplication::translate("Form", "PushButton", 0, QApplication::UnicodeUTF8));
lineEdit->setText(QString());
Q_UNUSED(Form);
} // retranslateUi
// **************** My Own Code *********************
public slots:
void Custom();
//******* My Own Code *********************
};
// **************** My Own Code *********************
void Ui_Form::Custom()
{
FILE * pFile;
pFile = fopen ("C:/Documents and Settings/Ahmed Osama/Desktop/myfile.txt","w");
}
// **************** My Own Code *********************
namespace Ui {
class Form: public Ui_Form {};
} // namespace Ui
QT_END_NAMESPACE
#endif // UI_TEST_H
Thanks
Everything goes sooo fine till now . However when I want to create my own slot , nothing
is happened (i.e. slot didn't work !! )
The purpose of my App : when the user press a button , an empty .txt file 'll be created .
I'm working under MS Win XP , & I've tried to run it over Linux to find out the problem . I've such that output :
Object::connect: No such slot QDialog::Custom()
Object::connect: (sender name: 'pushButton')
Object::connect: (receiver name: 'Form')
Though , I've add such this slot "Custom" @ QTDesign .
I've got .exe BUT the slot never responds ( i.e. Createing the file )
I've added a little piece of code @ the header file which was generated , is that true !!
I'm using :
- qt-win-opensource-4.4.0
- qmake to build the project
-MinGw
N.B. : I've created the slot , according to what I've understand from QT Assistant
So , What' the problem @ My Code :
/************************************************** ******************************
** Form generated from reading ui file 'Test.ui'
**
** Created: Mon Jun 2 06:29:48 2008
** by: Qt User Interface Compiler version 4.4.0
**
** WARNING! All changes made in this file will be lost when recompiling ui file!
************************************************** ******************************/
#ifndef UI_TEST_H
#define UI_TEST_H
#include <QtCore/QVariant>
#include <QtGui/QAction>
#include <QtGui/QApplication>
#include <QtGui/QButtonGroup>
#include <QtGui/QLineEdit>
#include <QtGui/QPushButton>
#include <QtGui/QWidget>
// **************** My Own Code *********************
#include <stdio.h>
// **************** My Own Code *********************
QT_BEGIN_NAMESPACE
class Ui_Form
{
public:
QPushButton *pushButton;
QLineEdit *lineEdit;
void setupUi(QWidget *Form)
{
if (Form->objectName().isEmpty())
Form->setObjectName(QString::fromUtf8("Form"));
Form->resize(475, 393);
pushButton = new QPushButton(Form);
pushButton->setObjectName(QString::fromUtf8("pushButton"));
pushButton->setGeometry(QRect(170, 190, 75, 24));
lineEdit = new QLineEdit(Form);
lineEdit->setObjectName(QString::fromUtf8("lineEdit"));
lineEdit->setGeometry(QRect(160, 90, 113, 20));
retranslateUi(Form);
QObject::connect(pushButton, SIGNAL(pressed()), Form, SLOT(Custom()));
QMetaObject::connectSlotsByName(Form);
} // setupUi
void retranslateUi(QWidget *Form)
{
Form->setWindowTitle(QApplication::translate("Form", "Form", 0, QApplication::UnicodeUTF8));
pushButton->setText(QApplication::translate("Form", "PushButton", 0, QApplication::UnicodeUTF8));
lineEdit->setText(QString());
Q_UNUSED(Form);
} // retranslateUi
// **************** My Own Code *********************
public slots:
void Custom();
//******* My Own Code *********************
};
// **************** My Own Code *********************
void Ui_Form::Custom()
{
FILE * pFile;
pFile = fopen ("C:/Documents and Settings/Ahmed Osama/Desktop/myfile.txt","w");
}
// **************** My Own Code *********************
namespace Ui {
class Form: public Ui_Form {};
} // namespace Ui
QT_END_NAMESPACE
#endif // UI_TEST_H
Thanks