新手求助QWorkspace 新建窗口
刚学qt看到多文档这块,关于QWorkspace这个类,我的例子中有平铺,层叠。我想做一个可以新建一个窗口不知道怎么办才好,我使了一个代码不好用,求大侠们帮帮忙!谢谢大家!
QAction *xinjian = new QAction(tr("新建"),this);
connect(xinjian,SIGNAL(triggered()),workSpace,SLOT(xinjian()));
layoutMenu->addAction(xinjian);//这是菜单部分
void MainWidget::xinjian()
{
workSpace = new QWorkspace;
setCentralWidget(workSpace);
QMainWindow *window4 = new QMainWindow;
window4->setWindowTitle(tr("窗口4"));
QTextEdit *edit4 = new QTextEdit;
edit4->setText(tr("窗口 4"));
window4->setCentralWidget(edit4);
workSpace->addWindow(window4);
}//这是槽函数
这样一点反映都没有,求助!!!非常感谢了!
[最优解释]
应该是connect(xinjian,SIGNAL(triggered()),this,SLOT(xinjian()));
[其他解释]
workSpace = new QWorkspace;
setCentralWidget(workSpace);
QMainWindow *window4 = new QMainWindow;
window4->setWindowTitle(tr("窗口4"));
QTextEdit *edit4 = new QTextEdit;
edit4->setText(tr("窗口 4"));
window4->setCentralWidget(edit4);
QWidget *w=workSpace->addWindow(window4);
w->setVisible(true);这个试试
[其他解释]
workSpace = new QWorkspace(this);试试
[其他解释]