本文整理汇总了C++中QPushButton::parent方法的典型用法代码示例。如果您正苦于以下问题:C++ QPushButton::parent方法的具体用法?C++ QPushButton::parent怎么用?C++ QPushButton::parent使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QPushButton
的用法示例。
在下文中一共展示了QPushButton::parent方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: eventFilter
//------------------------------------------------------------------------------
bool ctkFileDialog::eventFilter(QObject *obj, QEvent *event)
{
Q_D(ctkFileDialog);
QPushButton* button = d->acceptButton();
QDialogButtonBox* dialogButtonBox = qobject_cast<QDialogButtonBox*>(obj);
if (obj == button && event->type() == QEvent::EnabledChange &&
!d->IgnoreEvent)
{
d->IgnoreEvent = true;
d->AcceptButtonState = button->isEnabledTo(qobject_cast<QWidget*>(button->parent()));
button->setEnabled(d->AcceptButtonEnable && d->AcceptButtonState);
d->IgnoreEvent = false;
}
else if (obj == button && event->type() == QEvent::Destroy)
{
// The accept button is deleted probably because setAcceptMode() is being called.
// observe the parent to check when the accept button is added back
obj->parent()->installEventFilter(this);
}
else if (dialogButtonBox && event->type() == QEvent::ChildAdded)
{
dynamic_cast<QChildEvent*>(event)->child()->installEventFilter(this);
}
return QFileDialog::eventFilter(obj, event);
}
示例2: selectDate
void QgsAttributeEditor::selectDate()
{
QPushButton *pb = qobject_cast<QPushButton *>( sender() );
if ( !pb )
return;
QWidget *hbox = qobject_cast<QWidget *>( pb->parent() );
if ( !hbox )
return;
QLineEdit *le = hbox->findChild<QLineEdit *>();
if ( !le )
return;
QDialog *dlg = new QDialog();
dlg->setWindowTitle( tr( "Select a date" ) );
QVBoxLayout *vl = new QVBoxLayout( dlg );
QCalendarWidget *cw = new QCalendarWidget( dlg );
cw->setSelectedDate( QDate::fromString( le->text(), Qt::ISODate ) );
vl->addWidget( cw );
QDialogButtonBox *buttonBox = new QDialogButtonBox( dlg );
buttonBox->addButton( QDialogButtonBox::Ok );
buttonBox->addButton( QDialogButtonBox::Cancel );
vl->addWidget( buttonBox );
connect( buttonBox, SIGNAL( accepted() ), dlg, SLOT( accept() ) );
connect( buttonBox, SIGNAL( rejected() ), dlg, SLOT( reject() ) );
if ( dlg->exec() == QDialog::Accepted )
{
le->setText( cw->selectedDate().toString( Qt::ISODate ) );
}
}
示例3: observeAcceptButton
//------------------------------------------------------------------------------
void ctkFileDialogPrivate::observeAcceptButton()
{
Q_Q(ctkFileDialog);
QPushButton* button = this->acceptButton();
Q_ASSERT(button);
this->AcceptButtonState =
button->isEnabledTo(qobject_cast<QWidget*>(button->parent()));
// TODO: catching the event of the enable state is not enough, if the user
// double click on the file, the dialog will be accepted, that event should
// be intercepted as well
button->installEventFilter(q);
}
示例4: eventFilter
//------------------------------------------------------------------------------
bool ctkFileDialog::eventFilter(QObject *obj, QEvent *event)
{
Q_D(ctkFileDialog);
QPushButton* button = d->acceptButton();
if (obj == button && event->type() == QEvent::EnabledChange &&
!d->IgnoreEvent)
{
d->IgnoreEvent = true;
d->AcceptButtonState = button->isEnabledTo(qobject_cast<QWidget*>(button->parent()));
button->setEnabled(d->AcceptButtonEnable && d->AcceptButtonState);
d->IgnoreEvent = false;
}
return QFileDialog::eventFilter(obj, event);
}
示例5: init
//------------------------------------------------------------------------------
void ctkFileDialogPrivate::init()
{
Q_Q(ctkFileDialog);
QPushButton* button = this->acceptButton();
Q_ASSERT(button);
this->AcceptButtonState =
button->isEnabledTo(qobject_cast<QWidget*>(button->parent()));
// TODO: catching the event of the enable state is not enough, if the user
// double click on the file, the dialog will be accepted, that event should
// be intercepted as well
button->installEventFilter(q);
QObject::connect(this->listView()->selectionModel(),
SIGNAL(selectionChanged(QItemSelection,QItemSelection)),
q, SLOT(onSelectionChanged()));
}
示例6: selectFileName
void QgsAttributeEditor::selectFileName()
{
QPushButton *pb = qobject_cast<QPushButton *>( sender() );
if ( !pb )
return;
QWidget *hbox = qobject_cast<QWidget *>( pb->parent() );
if ( !hbox )
return;
QLineEdit *le = hbox->findChild<QLineEdit *>();
if ( !le )
return;
QString fileName = QFileDialog::getOpenFileName( 0 , tr( "Select a file" ) );
if ( fileName.isNull() )
return;
le->setText( QDir::toNativeSeparators( fileName ) );
}
示例7: 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());
}