不能使用父类的信号?
others:
话说,后来,在群上稍问了一下: 不能使用父类的信号作为发射源????得到的答案是,能用~在Q tCore很多的继承类的都用到了,群上的同志们是这样说的,然后,开始怀疑是不是自己写的代码有问题,将自己的详细过程写出:
自己定义了这么几个类:
// first.
class mainWindow : public QMainWindow
{
Q_OBJECT
public:
mdiWindow * mdi;
...
};
// second
class mdiWindow: public QMdiArea
{
Q_OBJECT
public:
fileNew(); // 在fileNew()中有创建singleText的对象,放在内存的堆中。
...
};
// third
class singleText: public QTextEdit
{
Q_OBJECT
public slot:
test(); // 弹出一个QMessageBox的对话框,用于测试函数。
...
};
因为在QTextEdit中有信号 void QMdiArea::subWindowActivated ( QMdiSubWindow * window ) [signal]
由于功能需要,想在mainWindow中使用到这个函数,于是就尝试connect这个信号,但了,为了排除其它因素的影响,就直接在第三个类中做测试了。
在第三个类的构造函数中添加下面的语句:
connect(this, SIGNAL(subWindowActiveated(QMdiSubWindow * window)), this, SLOT(book()));
结果,在进行窗口切换时,这个slot并没有响应,不知道是不是自己的connect方法出错,在这里请教大家如何能在子类中使用父类的信号?能这样使用的吗?