Cannot connect QMainWindow and QDialog

Posted by bartek on Stack Overflow See other posts from Stack Overflow or by bartek
Published on 2010-03-23T15:06:44Z Indexed on 2010/03/23 21:43 UTC
Read the original article Hit count: 464

Filed under:
|

Hi, I have a QMainWindow displaying a QDialog:

CalibrationDialog d(this);
d.exec();

My QMainWindow class has a signal:

signals:
void PenOn( QPoint p );

And QDialog has a slot:

public slots:
void on_PenON( QPoint p );

I tried connecting PenOn event to on_PenOn in two ways:

  1. After instantiating QDialog

   void MainWindow::on_actionC_triggered()
   {
     appState = CALIBR;

     CalibrationDialog d(this);
     connect( this, SIGNAL(PenOn(QPoint)), &d,SLOT(on_PenOn(QPoint)) );
     d.exec();
   }
  1. In QDialog constructor

    CalibrationDialog::CalibrationDialog(QWidget *parent) :
        QDialog(parent),
        ui(new Ui::CalibrationDialog)
    {
        ui->setupUi(this);

        [...]

        connect( parent, SIGNAL(PenOn(QPoint)), this,SLOT(on_PenOn(QPoint)) );
    }

None of this works :(. I'm emitting PenOn signal from MainWindow slot activated by another thread.

What am I doing wrong?

© Stack Overflow or respective owner

Related posts about qt4

Related posts about gui