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. How to call derived class' function from connected slot
Forum Updated to NodeBB v4.3 + New Features

How to call derived class' function from connected slot

Scheduled Pinned Locked Moved Solved General and Desktop
3 Posts 2 Posters 415 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
    maydin
    wrote on last edited by
    #1

    For example in TCP or WebSocket server when there is a connection we connect a signal to a slot like this:

    void Server::processMessage(QByteArray message)
    {
        QWebSocket *pClient = qobject_cast<QWebSocket *>(sender());
        if(pClient) {
            doSomething();
        }
    }
    

    I tried to make doSomething() virtual but it doesnt call the overridden doSomething() function in derived class. Is there anything I can do or I have to connect one more time from derived class?

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      Can you show your complete code ?

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      1
      • M Offline
        M Offline
        maydin
        wrote on last edited by
        #3

        It works as expected. I did a mistake in client program so therefore I couldn't see if it is called or not.

        It is solved now.

        After making 1 hour research about how signal-slot system works and what C++ compiler does, I decided to write here but found my mistake :)

        1 Reply Last reply
        1

        • Login

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