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

connection error in QObject::connect()

Scheduled Pinned Locked Moved Unsolved General and Desktop
connectsignal&slotqt 5.5
2 Posts 2 Posters 3.1k 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.
  • P Offline
    P Offline
    Pogi
    wrote on 17 Nov 2015, 16:52 last edited by Pogi
    #1

    how do i make syntax highlighting for c++ when creating thread in this forum?

    no matching function for call to 'MainWindow::connect(ServerManager*, const char*, MainWindow*, const char*)'
    QObject::connect(&server,SIGNAL(display()),this,SLOT(display()));

    why i keep getting this error.

    class MainWindow
    {
    ServerManager server;
    MainWindow()
    {
    QObject::connect(&server,SIGNAL(display()),this,SLOT(display()));
    }
    private slots:
    void display();
    };

    void MainWindow::display()
    {
    std::string m;
    sf::Int32 i;
    server.getPacket() >> m >> i;
    if ( i == 0 )
    {
    ui->clientList->addItem(QString::fromStdString("m"));
    }
    }

    class ServerManager
    {
    public:
    void test();
    signals:
    void display();
    }

    void ServerManager::test()
    {
    emit display();
    }

    1 Reply Last reply
    0
    • B Offline
      B Offline
      bsomervi
      wrote on 17 Nov 2015, 17:54 last edited by
      #2

      Both your classes need to inherit from QObject for the signal/slot mechanism to work.

      Code blocks are either preceded by 4 spaces (good for one liners):

      int variable;
      

      or they can be enclosed by `` ` (triple back ticks, good for inline elements and longer blocks):

      #include <iostream>
      
      int main (int argc, char * argv[]) {
         std::cout << "Hello, World!\n";
      }
      

      Google Markdown syntax for some more markup details.

      1 Reply Last reply
      0

      1/2

      17 Nov 2015, 16:52

      • Login

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