Passing String from Main to Slot
-
Hi All,
i tried to pass the string UG to my slot void Manuals::on_QRG_clicked(QString UG), so that the process is started. But i got
QMetaObject::connectSlotsByName: No matching signal for on_QRG_clicked(QString) .
My idea is that the string UG is not passed.
Whats wrong?
@Manuals::~Manuals()
{
delete ui;
QString UG = "acroread reference.pdf";}
void Manuals::on_QRG_clicked(QString UG)
{
QProcess acrobat;
acrobat.start(UG);
acrobat.waitForFinished(-1);
}@Thanks alot..
-
The message is clear: your signal and slot signatures don't fit. You need to have a signal that sends a QString before it can connect to a slot that is expecting a QString.
Also, line 4 of your code is completely obsolete, it does nothing.
-
i dont know what exactly you are trying but we will find out ;)
[quote author="mr_maddog" date="1372160625"]
QMetaObject::connectSlotsByName: No matching signal for on_QRG_clicked(QString) .[/quote]This erro essage says that "QMetaObject::connectSlotsByName()":http://qt-project.org/doc/qt-4.8/qmetaobject.html#connectSlotsByName doesn't find any slot to connect the slot to. Meaning a child object with the object name "QRG" is missing (which should emit the clicked-signal).
I also don't know why you create a QString object in the constructor. Nevertheless it will be destroyed right on the next line, because it is created on the stack and running out of scope (destructor method).
-
[quote author="Skh1002" date="1372171146"]Raven-worx meant you create UG string in destructor, not in constructor. Maybe, you wanted to do that in constructor instead?[/quote]
This only won't help either. Scope still stays the same and the string he instantiates there wont be the argument he expects in the slot...