本文整理汇总了C++中QPushButton::pos方法的典型用法代码示例。如果您正苦于以下问题:C++ QPushButton::pos方法的具体用法?C++ QPushButton::pos怎么用?C++ QPushButton::pos使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QPushButton
的用法示例。
在下文中一共展示了QPushButton::pos方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: keyPressEvent
void TaskView::keyPressEvent(QKeyEvent* ke)
{
if (ActiveCtrl && ActiveDialog) {
if (ke->key() == Qt::Key_Return || ke->key() == Qt::Key_Enter) {
// get all buttons of the complete task dialog
QList<QPushButton*> list = this->findChildren<QPushButton*>();
for (int i=0; i<list.size(); ++i) {
QPushButton *pb = list.at(i);
if (pb->isDefault() && pb->isVisible()) {
if (pb->isEnabled()) {
#if defined(FC_OS_MACOSX)
// #0001354: Crash on using Enter-Key for confirmation of chamfer or fillet entries
QPoint pos = QCursor::pos();
QCursor::setPos(pb->parentWidget()->mapToGlobal(pb->pos()));
#endif
pb->click();
#if defined(FC_OS_MACOSX)
QCursor::setPos(pos);
#endif
}
return;
}
}
}
else if (ke->key() == Qt::Key_Escape) {
// get only the buttons of the button box
QDialogButtonBox* box = ActiveCtrl->standardButtons();
QList<QAbstractButton*> list = box->buttons();
for (int i=0; i<list.size(); ++i) {
QAbstractButton *pb = list.at(i);
if (box->buttonRole(pb) == QDialogButtonBox::RejectRole) {
if (pb->isEnabled()) {
#if defined(FC_OS_MACOSX)
// #0001354: Crash on using Enter-Key for confirmation of chamfer or fillet entries
QPoint pos = QCursor::pos();
QCursor::setPos(pb->parentWidget()->mapToGlobal(pb->pos()));
#endif
pb->click();
#if defined(FC_OS_MACOSX)
QCursor::setPos(pos);
#endif
}
return;
}
}
}
}
else {
QScrollArea::keyPressEvent(ke);
}
}
示例2: tabButton
// QTabBar::setTabButton(index, closeSide, closeButton);
void tst_QTabBar::tabButton()
{
QFETCH(QTabBar::ButtonPosition, position);
QTabBar::ButtonPosition otherSide = (position == QTabBar::LeftSide ? QTabBar::RightSide : QTabBar::LeftSide);
QTabBar tabbar;
tabbar.resize(500, 200);
tabbar.show();
QTRY_VERIFY(tabbar.isVisible());
tabbar.setTabButton(-1, position, 0);
QVERIFY(tabbar.tabButton(-1, position) == 0);
QVERIFY(tabbar.tabButton(0, position) == 0);
tabbar.addTab("foo");
QCOMPARE(tabbar.count(), 1);
tabbar.setTabButton(0, position, 0);
QVERIFY(tabbar.tabButton(0, position) == 0);
QPushButton *button = new QPushButton;
button->show();
button->setText("hi");
button->resize(10, 10);
QTRY_VERIFY(button->isVisible());
QTRY_VERIFY(button->isVisible());
tabbar.setTabButton(0, position, button);
QCOMPARE(tabbar.tabButton(0, position), static_cast<QWidget *>(button));
QTRY_VERIFY(!button->isHidden());
QVERIFY(tabbar.tabButton(0, otherSide) == 0);
QCOMPARE(button->parent(), static_cast<QObject *>(&tabbar));
QVERIFY(button->pos() != QPoint(0, 0));
QPushButton *button2 = new QPushButton;
tabbar.setTabButton(0, position, button2);
QVERIFY(button->isHidden());
}