QT5笔记: 25. 非模态的自定义对话框
- 窗口对象为QDialog
- 显示方法为 show(); locateCell->show();
- 可以通过public方法或者信号槽机制获取非模态窗口的信息
例子:非模态窗口,为主窗口数据输入吧
void MainWindow::on_actTab_Locate_triggered()
{
ui->actTab_Locate->setEnabled(false);
locateCell = new DialogLocateCell(this);
locateCell->setAttribute(Qt::WA_DeleteOnClose);
Qt::WindowFlags flags = locateCell->windowFlags();
// locateCell->setWindowFlags(flags | Qt::WindowStaysOnTopHint);
locateCell->setRowRange(model->rowCount());
locateCell->setColRange(model->columnCount());
QModelIndex curIndex = selectedModel->currentIndex();
if (curIndex.isValid()) {
locateCell->setRowNumber(curIndex.row() + 1);
locateCell->setColNumber(curIndex.column() + 1);
}
connect(locateCell, SIGNAL(setCellContent(int, int, QString)), this, SLOT(setCellContent(int, int, QString)));//信号槽机制传递消息
locateCell->show();
}