当前位置: 首页>>代码示例>>C++>>正文


C++ QTabWidget::addAction方法代码示例

本文整理汇总了C++中QTabWidget::addAction方法的典型用法代码示例。如果您正苦于以下问题:C++ QTabWidget::addAction方法的具体用法?C++ QTabWidget::addAction怎么用?C++ QTabWidget::addAction使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在QTabWidget的用法示例。


在下文中一共展示了QTabWidget::addAction方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: setStandardKeys


//.........这里部分代码省略.........
      button->setToolTip(button->text().remove("&")  + " " +
                         button->shortcut().toString(QKeySequence::NativeText));
    }
  }
  if (!hasShortcut)
  {
    QDialogButtonBox* bb = widget->findChild<QDialogButtonBox*>();
    if (bb)
    {
      QList<QAbstractButton*> buttons =  bb->buttons();
      for (int i = 0; i < buttons.size(); ++i)
      {
        QAbstractButton *bbutton = buttons.at(i);
        QDialogButtonBox::ButtonRole btnrole = bb->buttonRole(buttons.at(i));
        if (btnrole == QDialogButtonBox::AcceptRole)
        {
          bbutton->setShortcut(QKeySequence::Save);
          bbutton->setToolTip(bbutton->text().remove("&")  + " " +
                              bbutton->shortcut().toString(QKeySequence::NativeText));

        }
        else if (btnrole == QDialogButtonBox::RejectRole)
        {
          bbutton->setShortcut(QKeySequence::Close);
          bbutton->setToolTip(bbutton->text().remove("&")  + " " +
                              bbutton->shortcut().toString(QKeySequence::NativeText));

        }
      }
    }
  }

  // For Close
  hasShortcut = false;
  button = widget->findChild<QPushButton*>("_close");
  if (button)
  {
    button->setShortcut(QKeySequence::Close);
    button->setToolTip(button->text().remove("&")  + " " +
                       button->shortcut().toString(QKeySequence::NativeText));
    hasShortcut = true;
  }
  if (!hasShortcut) // Because some screens have both
  {
    // For Post
    button = widget->findChild<QPushButton*>("_cancel");
    if (button)
    {
      button->setShortcut(QKeySequence::Close);
      button->setToolTip(button->text().remove("&")  + " " +
                         button->shortcut().toString(QKeySequence::NativeText));
    }
  }

  // For New
  button = widget->findChild<QPushButton*>("_new");
  if (button)
  {
    button->setShortcut(QKeySequence::New);
    button->setToolTip(button->text().remove("&")  + " " +
                       button->shortcut().toString(QKeySequence::NativeText));
    hasShortcut = true;
  }

  // For Print
  button = widget->findChild<QPushButton*>("_print");
  if (button)
  {
    button->setShortcut(QKeySequence::Print);
    button->setToolTip(button->text().remove("&")  + " " +
                       button->shortcut().toString(QKeySequence::NativeText));
    hasShortcut = true;
  }

  // For Query
  button = widget->findChild<QPushButton*>("_query");
  if (button)
  {
    button->setShortcut(QKeySequence::Refresh);
    button->setToolTip(button->text().remove("&")  + " " +
                       button->shortcut().toString(QKeySequence::NativeText));
    hasShortcut = true;
  }

  // Page up/down for tab widgets
  QTabWidget* tab = widget->findChild<QTabWidget*>();
  if (tab)
  {
    TabWidgetNavigtor* tabNav = new TabWidgetNavigtor(tab, widget);
    QAction* pagedownAct = new QAction(tab);
    pagedownAct->setShortcut(QKeySequence::MoveToNextPage);
    pagedownAct->connect(pagedownAct, SIGNAL(triggered()), tabNav, SLOT(pageDown()));
    tab->addAction(pagedownAct);

    QAction* pageupAct = new QAction(tab);
    pageupAct->setShortcut(QKeySequence::MoveToPreviousPage);
    pageupAct->connect(pageupAct, SIGNAL(triggered()), tabNav, SLOT(pageUp()));
    tab->addAction(pageupAct);
  }
}
开发者ID:AlFoX,项目名称:qt-client,代码行数:101,代码来源:shortcuts.cpp


注:本文中的QTabWidget::addAction方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。