QT5笔记: 25. 非模态的自定义对话框

  1. 窗口对象为QDialog
  2. 显示方法为 show(); locateCell->show();
  3. 可以通过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();
}
posted @ 2023-03-16 10:59  echo_lovely  阅读(34)  评论(0编辑  收藏  举报