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..


  • Moderators

    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.


  • Moderators

    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).



  • Raven-worx meant you create UG string in destructor, not in constructor. Maybe, you wanted to do that in constructor instead?


  • Moderators

    [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...



  • Well, I should have said that maybe he wanted to keep a member variable and initialise it in the constructor. I was too much in a hurry :-)


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.