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: 459
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:
- 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();
}
- 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