本文整理汇总了C++中QWidget::isAncestorOf方法的典型用法代码示例。如果您正苦于以下问题:C++ QWidget::isAncestorOf方法的具体用法?C++ QWidget::isAncestorOf怎么用?C++ QWidget::isAncestorOf使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QWidget
的用法示例。
在下文中一共展示了QWidget::isAncestorOf方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: setCurrentIndex
/*!
\property QStackedLayout::currentIndex
\brief the index position of the widget that is visible
The current index is -1 if there is no current widget.
\sa currentWidget(), indexOf()
*/
void QStackedLayout::setCurrentIndex(int index)
{
Q_D(QStackedLayout);
QWidget *prev = currentWidget();
QWidget *next = widget(index);
if (!next || next == prev)
return;
bool reenableUpdates = false;
QWidget *parent = parentWidget();
if (parent && parent->updatesEnabled()) {
reenableUpdates = true;
parent->setUpdatesEnabled(false);
}
QPointer<QWidget> fw = parent ? parent->window()->focusWidget() : 0;
const bool focusWasOnOldPage = fw && (prev && prev->isAncestorOf(fw));
if (prev) {
prev->clearFocus();
if (d->stackingMode == StackOne)
prev->hide();
}
d->index = index;
next->raise();
next->show();
// try to move focus onto the incoming widget if focus
// was somewhere on the outgoing widget.
if (parent) {
if (focusWasOnOldPage) {
// look for the best focus widget we can find
if (QWidget *nfw = next->focusWidget())
nfw->setFocus();
else {
// second best: first child widget in the focus chain
if (QWidget *i = fw) {
while ((i = i->nextInFocusChain()) != fw) {
if (((i->focusPolicy() & Qt::TabFocus) == Qt::TabFocus)
&& !i->focusProxy() && i->isVisibleTo(next) && i->isEnabled()
&& next->isAncestorOf(i)) {
i->setFocus();
break;
}
}
// third best: incoming widget
if (i == fw )
next->setFocus();
}
}
}
}
if (reenableUpdates)
parent->setUpdatesEnabled(true);
emit currentChanged(index);
}
示例2: isAncestorOf
bool QWidgetProto::isAncestorOf(const QWidget *child) const
{
QWidget *item = qscriptvalue_cast<QWidget*>(thisObject());
if (item)
return item->isAncestorOf(child);
return false;
}
示例3: getfocus
// ---------------------------------------------------------------------
string Form::getfocus()
{
QWidget *w=app->focusWidget();
if (!w || !this->children.size()) return "";
for (int i=this->children.size()-1; 0<=i; i--) {
QWidget *c;
if ((c=this->children.at(i)->widget) && (w==c || c->isAncestorOf(w)))
return this->children.at(i)->id;
}
return "";
}
示例4: window
IDirectFBSurface *QDirectFBWindowSurface::surfaceForWidget(const QWidget *widget, QRect *rect) const
{
Q_ASSERT(widget);
if (!dfbSurface)
return 0;
QWidget *win = window();
Q_ASSERT(win);
if (rect) {
if (win == widget) {
*rect = widget->rect();
} else {
*rect = QRect(widget->mapTo(win, QPoint(0, 0)), widget->size());
}
}
Q_ASSERT(win == widget || win->isAncestorOf(widget));
return dfbSurface;
}
示例5: setCurrentIndex
void StackLayout::setCurrentIndex(int index)
{
QWidget *prev = currentWidget();
QWidget *next = widget(index);
if (!next || next == prev)
return;
_index = index;
if(!parent()) return;
bool reenableUpdates = false;
QWidget *parent = parentWidget();
if (parent && parent->updatesEnabled()) {
reenableUpdates = true;
parent->setUpdatesEnabled(false);
}
QWidget *fw = parent ? parent->window()->focusWidget() : 0;
if (prev) {
prev->clearFocus();
if (_mode == StackOne)
prev->hide();
}
next->raise();
next->show();
// try to move focus onto the incoming widget if focus
// was somewhere on the outgoing widget.
if (parent) {
if (fw && (prev && prev->isAncestorOf(fw))) { // focus was on old page
// look for the best focus widget we can find
if (QWidget *nfw = next->focusWidget())
nfw->setFocus();
else {
// second best: first child widget in the focus chain
QWidget *i = fw;
while ((i = i->nextInFocusChain()) != fw) {
if (((i->focusPolicy() & Qt::TabFocus) == Qt::TabFocus)
&& !i->focusProxy() && i->isVisibleTo(next) && i->isEnabled()
&& next->isAncestorOf(i)) {
i->setFocus();
break;
}
}
// third best: incoming widget
if (i == fw )
next->setFocus();
}
}
}
if (reenableUpdates)
parent->setUpdatesEnabled(true);
if (_mode == StackOne)
// expandingDirections() might have changed, so invalidate():
invalidate();
}
示例6: eventFilter
bool KCompletionBox::eventFilter( QObject *o, QEvent *e )
{
int type = e->type();
QWidget *wid = qobject_cast<QWidget*>(o);
if (o == this) {
return false;
}
if (wid && wid == d->m_parent &&
(type == QEvent::Move || type == QEvent::Resize)) {
hide();
return false;
}
if (wid && (wid->windowFlags() & Qt::Window) &&
type == QEvent::Move && wid == d->m_parent->window()) {
hide();
return false;
}
if (type == QEvent::MouseButtonPress && (wid && !isAncestorOf(wid))) {
if (!d->emitSelected && currentItem() && !qobject_cast<QScrollBar*>(o)) {
Q_ASSERT(currentItem());
emit currentTextChanged(currentItem()->text() );
}
hide();
e->accept();
return true;
}
if (wid && wid->isAncestorOf(d->m_parent) && isVisible()) {
if ( type == QEvent::KeyPress ) {
QKeyEvent *ev = static_cast<QKeyEvent *>( e );
switch ( ev->key() ) {
case Qt::Key_Backtab:
if ( d->tabHandling && (ev->modifiers() == Qt::NoButton ||
(ev->modifiers() & Qt::ShiftModifier)) ) {
up();
ev->accept();
return true;
}
break;
case Qt::Key_Tab:
if ( d->tabHandling && (ev->modifiers() == Qt::NoButton) ) {
down();
// #65877: Key_Tab should complete using the first
// (or selected) item, and then offer completions again
if (count() == 1) {
KLineEdit* parent = qobject_cast<KLineEdit*>(d->m_parent);
if (parent) {
parent->doCompletion(currentItem()->text());
} else {
hide();
}
}
ev->accept();
return true;
}
break;
case Qt::Key_Down:
down();
ev->accept();
return true;
case Qt::Key_Up:
// If there is no selected item and we've popped up above
// our parent, select the first item when they press up.
if ( !selectedItems().isEmpty() ||
mapToGlobal( QPoint( 0, 0 ) ).y() >
d->m_parent->mapToGlobal( QPoint( 0, 0 ) ).y() )
up();
else
down();
ev->accept();
return true;
case Qt::Key_PageUp:
pageUp();
ev->accept();
return true;
case Qt::Key_PageDown:
pageDown();
ev->accept();
return true;
case Qt::Key_Escape:
canceled();
ev->accept();
return true;
case Qt::Key_Enter:
case Qt::Key_Return:
if ( ev->modifiers() & Qt::ShiftModifier ) {
hide();
ev->accept(); // Consume the Enter event
return true;
}
break;
case Qt::Key_End:
if ( ev->modifiers() & Qt::ControlModifier )
{
end();
ev->accept();
//.........这里部分代码省略.........