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. QObject::connect()

QObject::connect()

Scheduled Pinned Locked Moved Unsolved General and Desktop
connectconnect failureqt5.5.0qobject
6 Posts 3 Posters 3.3k Views
  • 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.
  • L Offline
    L Offline
    Lorence
    wrote on 1 Dec 2015, 10:11 last edited by
    #1

    why cant i get rid of this error?

    error: no matching function for call to 'MainWindow::connect(PlayList*&, const char*, __gnu_cxx::__alloc_traits<std::allocator<Track> >::value_type*, const char*)'
    QObject::connect(ui->tab1List,SIGNAL(clickedToPlay()),&playList[playList.size()-1],SLOT(play()));
    ^
    heres my code:
    http://pastebin.com/4cpKTYSB

    1 Reply Last reply
    0
    • T Offline
      T Offline
      TheBadger
      wrote on 1 Dec 2015, 10:51 last edited by TheBadger 12 Jan 2015, 10:54
      #2

      @Lorence
      From your code class Track does not derive from QObject, thus you can not connect to it:

      class Track : public QObject 
      {
          Q_OBJECT
          ...
      };
      

      Edit:
      Also the following looks strange:

      std::vector<Track> playList;
      

      Since you have a class called PlayList. If that is correct I suggest calling your variable trackList instead.


      Check out my SpellChecker Plugin for Qt Creator @ https://github.com/CJCombrink/SpellChecker-Plugin

      1 Reply Last reply
      0
      • T Offline
        T Offline
        TheBadger
        wrote on 1 Dec 2015, 11:00 last edited by
        #3

        Another issue, your class Track does not have a slot called play(), there is a playSong() that I suspect you wanted to call.

        If you are using Qt 5 use the new connect syntax instead and you will reduce such errors:

        connect(ui->tab1List, &PlayList::clickedToPlay, &playList.back(), &Track::playSong);
        

        PS: I replaced the playList[playList.size()-1] with the std::vector::back() function call since it should do the same but the intent is clear.


        Check out my SpellChecker Plugin for Qt Creator @ https://github.com/CJCombrink/SpellChecker-Plugin

        L 1 Reply Last reply 3 Dec 2015, 14:23
        0
        • L Offline
          L Offline
          Lorence
          wrote on 3 Dec 2015, 14:10 last edited by
          #4

          Guys!!! sorry for the late reply, i was so busy from my school projects

          heres the error:
          error: use of deleted function 'Track::Track(const Track&)'
          { ::new(static_cast<void*>(__p)) _T1(std::forward<_Args>(__args)...); }
          ^

          heres the new code:
          http://pastebin.com/PgR8bUeg

          1 Reply Last reply
          0
          • M Offline
            M Offline
            mrjj
            Lifetime Qt Champion
            wrote on 3 Dec 2015, 14:14 last edited by SGaist 12 Mar 2015, 14:26
            #5

            hi
            you have declared your list as using non pointers.
            std::vector<Track> playList;
            So track must be copy able.
            but since its a QObject, its not allowed.
            So it must be
            std::vector<Track*> playList;

            Thats why you get Track(const Track&) error

            [edit: fixed typo -> QObject are not copyable SGaist]

            1 Reply Last reply
            1
            • T TheBadger
              1 Dec 2015, 11:00

              Another issue, your class Track does not have a slot called play(), there is a playSong() that I suspect you wanted to call.

              If you are using Qt 5 use the new connect syntax instead and you will reduce such errors:

              connect(ui->tab1List, &PlayList::clickedToPlay, &playList.back(), &Track::playSong);
              

              PS: I replaced the playList[playList.size()-1] with the std::vector::back() function call since it should do the same but the intent is clear.

              L Offline
              L Offline
              Lorence
              wrote on 3 Dec 2015, 14:23 last edited by Lorence 12 Mar 2015, 14:24
              #6

              @TheBadger
              I tried to investigate the error, and i found where it is coming from
              its from this line
              playList.emplace_back(ui->song->text().toStdString());
              which is written before the connect() in the code

              1 Reply Last reply
              0

              5/6

              3 Dec 2015, 14:14

              • Login

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