Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Passing String from Main to Slot
Forum Updated to NodeBB v4.3 + New Features

Passing String from Main to Slot

Scheduled Pinned Locked Moved General and Desktop
6 Posts 4 Posters 1.6k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    mr_maddog
    wrote on last edited by
    #1

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

    1 Reply Last reply
    0
    • sierdzioS Offline
      sierdzioS Offline
      sierdzio
      Moderators
      wrote on last edited by
      #2

      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.

      (Z(:^

      1 Reply Last reply
      0
      • raven-worxR Offline
        raven-worxR Offline
        raven-worx
        Moderators
        wrote on last edited by
        #3

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

        --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
        If you have a question please use the forum so others can benefit from the solution in the future

        1 Reply Last reply
        0
        • S Offline
          S Offline
          Skh1002
          wrote on last edited by
          #4

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

          1 Reply Last reply
          0
          • raven-worxR Offline
            raven-worxR Offline
            raven-worx
            Moderators
            wrote on last edited by
            #5

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

            --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
            If you have a question please use the forum so others can benefit from the solution in the future

            1 Reply Last reply
            0
            • S Offline
              S Offline
              Skh1002
              wrote on last edited by
              #6

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

              1 Reply Last reply
              0

              • Login

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • Users
              • Groups
              • Search
              • Get Qt Extensions
              • Unsolved