Inheritance and Slots/Signals
Hello to all, I have problem with ^^subj^^.
Code:
{
Q_OBJECT
private:
QVector<QString> qvStates;
public:
~HttpGetFile();
///Запуск процесса скачки файла, конец по получению сигнала siDone().
void start( const QString& qstrUrlIn, QIODevice& ioDevice);
//QString qstrData;
private slots:
void slStateChanged ( int iState );
void slDone( bool bDone );
void slDataReadProgress ( int done, int total );
signals:
/** \brief Изменение статуса сокета (как-то так =)).
\param iState статус сокета, соотвественно могут быть:\n
0 - Отключено\n
1 - Поиск хоста\n
2 - Подключаюсь\n
3 - Отправка данных\n
4 - Приём данных\n
5 - Подключен\n
6 - Закрытие подключения
*/
void siStateChanged( const int iState );
/** \brief Завершающий сигнал сокета.
\param bError если тру тогда в iError номер ошибки.
\param iError номер ошибки. Соответственно номера ошибок:\n\n
<b>ошибки QHttp</b>\n
0 - Нет ошибки\n
1 - Неизвестная ошибка\n
2 - Хост не найден\n
3 - Сервер отказал в соединении\n
4 - Сервер закрыл соединение по беспределу\n
5 - Ответ сервера не удалось обработать\n
6 - Не удалось определить длину ответа сервера\n
7 - Запрос был прерван (abort())\n\n
<b>ошибки ParseUrl()</b>\n
8 - Адресс не УРЛ\n
9 - http:// сначало УРЛ не найдено
*/
void siDone( bool bError, const int iError );
/** \brief Комментарии излишни :)
\param done сколько уже скачалось
\param total общий размер файла (может быть 0, если серевер не даёт размер файла(редиска))
*/
void siDataReadProgress ( int done, int total );
/** \brief Сигнал используется в деструкторе (в внешних связях не замечен =))
*/
void siAbort();
public:
bool ParseUrl( const QString& qstrUrlIn, int& iError );
void ThrowError( const int iError );
};
and the second class, that's inherites first:
Code:
class MainPlugins: public HttpGetFile
{
public:
void GetXMLPluginsList( const QString& qstrUrl );
void SynchronizeWithLocalPlugins();
private:
void ThrowError(int iError, const QString& qstrError);
private slots:
void slDone1(bool bError, const int iError);
signals:
void siDone1(bool bError, const int iError);
private:
};
when in any function of second class I try to connect HIS (second class) signal with slot:
Code:
QObject::connect(this,
SIGNAL(siDone1
(bool,
const int)),
this,
SLOT(slDone1
(bool,
const int)));
all compiles ok, but when I try to run this, I get this:
Object::connect: No such signal HttpGetFile::siDone1(bool,int)
why this try connect to the first (HttpGetFile) slot?
help please.
Re: Inheritance and Slots/Signals
I think you need the Q_OBJECT macro in the second class.
Re: Inheritance and Slots/Signals
I think once you have "i" (like internet) and once you have "l" (like localization) - a spelling mistake.
Re: Inheritance and Slots/Signals
magland, you are right. This is strange thing, because when I wrote:
class MainPlugins: public HttpGetFile, public QObject
{
Q_OBJECT
....
I got errors, but if only how you advice all is ok, thanks!!!
Re: Inheritance and Slots/Signals
No, you could have solved this by putting QObject first in the inheritance list.
Regards
Re: Inheritance and Slots/Signals
Quote:
Originally Posted by
LMZ
class MainPlugins: public HttpGetFile, public QObject
A side note: HttpGetFile already is a QObject. Multiple inheritance from QObject is not supported.