C++/Qt 5.7 - QDialog to QMainWindow - signal not connecting to slot
Hello,
A follow on to this post of mine.
http://www.qtcentre.org/threads/6695...dow-to-QDialog
I've progressed a little, thanks to your help.
Another problem.
I'm emitting a signal early in the noobsForm init process, which is not getting called.
I've read somewhere that signals and slots are set up sometime in the process but are not guaranteed when.
I added a process events call, no help.
Is this my problem? If it is, is there any round it?
Regards
Code:
mainwindow.cpp
noobsForm myNoobs(listPart, file);
QObject::connect(&myNoobs,
SIGNAL(doFormat
(int,
bool)),
this, SLOT(formatSDcard(int, bool)));
this,
SLOT(writeNoobs
(int,
bool,
QString)));
QObject::connect(&myNoobs,
SIGNAL(doUpdateDriveDataList
()),
this, SLOT(getLogicalDrivesSlot()));
****
this,
SLOT(getUpdatedFileCount
(QString)));
****
myNoobs.exec();
void MainWindow
::getUpdatedFileCount(QString driveLetter
) //slot {
qDebug() << "getupdatedfilecountSlot" << driveLetter;
//getFileList(driveLetter);
//qDebug() << countFiles << "-" << countDirs;
//emit doUpdateFileList(countFiles, countDirs);
}
mainwindow.hpp
public slots:
bool formatSDcard(int type, bool remote);
void writeNoobs
(int which,
bool remote,
QString file);
void getLogicalDrives(); // find attached USB devices
void getUpdatedFileCount
(QString driveLetter
);
Code:
noobsForm.cpp
This is in the noobsForm init process:-
delay(1000); //process events - ? required
qDebug() << "passed letter" << (driveLetter + ":");
emit doGetFileCount(driveLetter + ":");
These are triggered by pushbuttons and work:-
emit doFormat(type, true);
emit doWriteNoobs(1, true, address);
emit doUpdateDriveDataList();
noobs.hpp
signals:
void doFormat(int, bool);
void doWriteNoobs
(int,
bool,
QString);
void doUpdateDriveDataList();
Debug output:-
passed letter "J:"
Re: C++/Qt 5.7 - QDialog to QMainWindow - signal not connecting to slot
What does it mean I'm emitting a signal early in the noobsForm init process ? Is the init process is the constructor ?
Re: C++/Qt 5.7 - QDialog to QMainWindow - signal not connecting to slot
Hello Lesiok,
Thanks for your response.
Quote:
Is the init process is the constructor ?
No.
Code:
ui(new Ui::noobsForm)
{
...
...
initInst();
}
void noobsForm::initInst()
{
...
...
delay(1000); //process events
qDebug() << "passed letter" << (driveLetter + ":");
emit doGetFileCount(driveLetter + ":");
...
...
}
Re: C++/Qt 5.7 - QDialog to QMainWindow - signal not connecting to slot
How not like yes ? initInst() is called from constructor. Signals are connected after them so what are you surprised that it does not work ?
Maybe you should first learn the basics of C++.