当窗口处于全屏模式时,Qt连接不起作用

时间:2016-12-04 01:59:31

标签: c++ qt user-interface signals-slots

我遇到了一些连接问题:

QAction* fs = new QAction(this);
fs->setShortcut(Qt::Key_F);
connect(fs, &QAction::triggered, this, &MainWindow::fullscreen);
menuBar()->addAction(fs);

全屏功能是:

if(!fullscreenMode)
{
    mouseMoved=time(0);
    this->menuBar()->hide();
    this->showFullScreen();
    fullscreenMode=true;
}
else
{
    this->menuBar()->show();
    timeBar->show();
    controlBar->show();
    this->showNormal();
    fullscreenMode=false;
    timeBar->visibilityChanged(true);
    controlBar->visibilityChanged(true);

}

我无法使用快捷键(F按钮)恢复正常模式,但我可以使用相同功能的双击来完成。我的错误在哪里?

1 个答案:

答案 0 :(得分:1)

答案是:

QShortcut* fullscreenShortcut = new QShortcut(QKeySequence(Qt::Key_F),this,SLOT(fullscreen()));