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. SOLVED - Qt slot problem - don't forget the Q_OBJECT macro!!!!!!
Forum Updated to NodeBB v4.3 + New Features

SOLVED - Qt slot problem - don't forget the Q_OBJECT macro!!!!!!

Scheduled Pinned Locked Moved General and Desktop
3 Posts 2 Posters 950 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.
  • P Offline
    P Offline
    philmacu
    wrote on last edited by
    #1

    Hi,
    I am currently writing a small project, in it I have an object (mainWindow.cpp) that has several slots that are triggered by time events. They all work fine. In my main class I have a member (serialPort.cpp) which is a class that controls a serial port, I am trying to set up a signal/slot that does a one shot. This will be used so that I can timeout if I don;t get any serial back.

    So a function in mainWindow.cpp ceates an instance of a serialPort.cpp at some time mainWindow.cpp starts the process to send serial data, I would like a one shot to 'go-off' at some time in the future if I don't have a response. When I try the following code I get a warning in my output dialog that the slot can't be found.

    in the header of serialPort.cpp
    private:

       QTimer *ATresponseTimer;
    

    private slots:

    void ATcommandResponseTimeout(void);

    In the constructor of serialPort.cpp

    ATresponseTimer = new QTimer;

    connect ( ATresponseTimer, SIGNAL ( timeout() ), this, SLOT ( ATcommandResponseTimeout () ) );

    ATresponseTimer->setSingleShot(true);

    ATresponseTimer->stop();

    also is serialPort.cpp
    void serialPort::ATcommandResponseTimeout(void)
    {
    // we sent an AT command but never got a response in time,
    qDebug() << "Modem response timed out";
    }

    The error I get is
    Object::connect: No such slot QMainWindow::ATcommandResponseTimeout():serialPort in serialPort.cpp:10

    I am sure I am forgetting to do something simple, any pointers ;-) would be great

    Phil

    1 Reply Last reply
    0
    • R Offline
      R Offline
      Rondog
      wrote on last edited by
      #2

      I would check the name of the slot (it is likely a typo in the name 'ATcommandResponseTimeout').

      You could do it another way possibly.

      You could use a timer (maybe one of your existing ones) to check if any data was received between events. All you need to do is set a variable every time you receive data and clear it on the timer event. If your variable is not set between events nothing was received. It might be simpler to implement.

      1 Reply Last reply
      0
      • P Offline
        P Offline
        philmacu
        wrote on last edited by
        #3

        Thanks Rondog, I went for a walk and a cup of coffee, when I got back I suddenly realised that I forgot to place Q_OBJECT in serialPort.h

        It re-emphasises the idea of taking a break when the wheels start falling off!

        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