I know this question has come up before but I can't get ride of the warning
Qt Code:
  1. QSocketNotifier: Socket notifiers cannot be enabled or disabled from another thread
To copy to clipboard, switch view to plain text mode 

I have a button class that monitors a GPIO line and emits a signal when a falling edge is detected. I am using a QSocketNotifier to monitor the gpio dev device. Following is my code in the button class for opening the devices and setting up the QSocketNotifier:
Qt Code:
  1. void Button::Open()
  2. {
  3. int retval;
  4.  
  5. d->m_fd = open(d->m_device.toLatin1().data(), O_RDONLY);
  6. if (d->m_fd < 0)
  7. {
  8. qDebug() << "Failed to open";
  9. return;
  10. }
  11.  
  12. retval = ioctl(d->m_fd, GPIO_GET_LINEEVENT_IOCTL, &d->m_request);
  13. if (retval < 0)
  14. {
  15. qDebug() << "Failed to ioctl";
  16. close(d->m_fd);
  17. return;
  18. }
  19.  
  20. d->m_notifier_p = new QSocketNotifier(
  21. d->m_fd, QSocketNotifier::Read, this);
  22. connect(d->m_notifier_p, &QSocketNotifier::activated,
  23. this, &Button::OnActivated);
  24. }
To copy to clipboard, switch view to plain text mode 

I am then creating the button in another class and moving it to its own thread.
Qt Code:
  1. Button *btn2_p = new Button(BUTTON_DEVICE, BTN2_LINE, 1);
  2. btn2_p->moveToThread(&m_btn2_thread);
  3. connect(&m_btn2_thread, &QThread::finished, btn2_p, &Button::deleteLater);
  4. connect(&m_btn2_thread, &QThread::started, btn2_p, &Button::Open);
  5. d->m_btn2_thread.start();;
To copy to clipboard, switch view to plain text mode 

The button does not have a parent and the open function should be getting called in the m_btn2_thread so the socket notifier is created in the m_btn2_thread.

What did I do wrong in my code to get this error message?