QWhatsThis的用法

  QWhatsThis,为任何widget提供简单的描述,回答"What's This?"这个问题。

  示例:(在MainWindow下运行) 

  定义全局变量 QAction *newAct; QMenu *fileMenu;

  void MainWindow::creatActions() {

    newAct = new QAction(tr("&New"), this); // 

    newAct->setWhatsThis(tr("Click this option to create a new file."));

  }

  void MainWindow::createMenu() {

    fileMenu = menuBar()->addMenu(tr("&File"));

    fileMenu->addAction(newAct);

  }

  当光标在New键上时,按shift+f1快捷键来显示描述信息。

  注意:当shift+f1快捷键被其他地方使用时,此处的快捷键就无效。

 

posted @ 2016-08-04 21:18  toby.zl  阅读(2705)  评论(0编辑  收藏  举报