本文整理汇总了C++中QWidget::focusProxy方法的典型用法代码示例。如果您正苦于以下问题:C++ QWidget::focusProxy方法的具体用法?C++ QWidget::focusProxy怎么用?C++ QWidget::focusProxy使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QWidget
的用法示例。
在下文中一共展示了QWidget::focusProxy方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: focusWidget
QWidget* kMyMoneyEdit::focusWidget() const
{
QWidget* w = m_edit;
while (w->focusProxy())
w = w->focusProxy();
return w;
}
示例2: setBuddy
/******************************************************************************
* Set a buddy widget.
* If it (or its focus proxy) is a radio button, create a focus widget.
* When the accelerator key is pressed, the focus widget then receives focus.
* That event triggers the selection of the radio button.
*/
void Label::setBuddy(QWidget *bud)
{
if(mRadioButton)
disconnect(mRadioButton, SIGNAL(destroyed()), this, SLOT(buddyDead()));
QWidget *w = bud;
if(w)
{
while(w->focusProxy())
w = w->focusProxy();
if(!w->inherits("QRadioButton"))
w = 0;
}
if(!w)
{
// The buddy widget isn't a radio button
QLabel::setBuddy(bud);
delete mFocusWidget;
mFocusWidget = 0;
mRadioButton = 0;
}
else
{
// The buddy widget is a radio button, so set a different buddy
if(!mFocusWidget)
mFocusWidget = new LabelFocusWidget(this);
QLabel::setBuddy(mFocusWidget);
mRadioButton = (QRadioButton *)bud;
connect(mRadioButton, SIGNAL(destroyed()), this, SLOT(buddyDead()));
}
}
示例3:
QWidget *QWidgetProto::focusProxy() const
{
QWidget *item = qscriptvalue_cast<QWidget*>(thisObject());
if (item)
return item->focusProxy();
return 0;
}
示例4: qwtSetTabOrder
static void qwtSetTabOrder(
QWidget *first, QWidget *second, bool withChildren )
{
QList<QWidget *> tabChain;
tabChain += first;
tabChain += second;
if ( withChildren )
{
QList<QWidget *> children = second->findChildren<QWidget *>();
QWidget *w = second->nextInFocusChain();
while ( children.contains( w ) )
{
children.removeAll( w );
tabChain += w;
w = w->nextInFocusChain();
}
}
for ( int i = 0; i < tabChain.size() - 1; i++ )
{
QWidget *from = tabChain[i];
QWidget *to = tabChain[i+1];
const Qt::FocusPolicy policy1 = from->focusPolicy();
const Qt::FocusPolicy policy2 = to->focusPolicy();
QWidget *proxy1 = from->focusProxy();
QWidget *proxy2 = to->focusProxy();
from->setFocusPolicy( Qt::TabFocus );
from->setFocusProxy( NULL);
to->setFocusPolicy( Qt::TabFocus );
to->setFocusProxy( NULL);
QWidget::setTabOrder( from, to );
from->setFocusPolicy( policy1 );
from->setFocusProxy( proxy1);
to->setFocusPolicy( policy2 );
to->setFocusProxy( proxy2 );
}
}
示例5: 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);
}
QWidget *fw = parent ? parent->window()->focusWidget() : 0;
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 (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);
emit currentChanged(index);
}
示例6: if
void Q3WidgetStack::raiseWidget(QWidget *w)
{
if (!w || w == invisible || w->parent() != this || w == topWidget)
return;
if (id(w) == -1)
addWidget(w);
if (!isVisible()) {
topWidget = w;
return;
}
if (w->maximumSize().width() < invisible->width()
|| w->maximumSize().height() < invisible->height())
invisible->setBackgroundMode(backgroundMode());
else if (invisible->backgroundMode() != NoBackground)
invisible->setBackgroundMode(NoBackground);
if (invisible->isHidden()) {
invisible->setGeometry(contentsRect());
invisible->lower();
invisible->show();
QApplication::sendPostedEvents(invisible, QEvent::ShowWindowRequest);
}
// try to move focus onto the incoming widget if focus
// was somewhere on the outgoing widget.
if (topWidget) {
QWidget * fw = window()->focusWidget();
if (topWidget->isAncestorOf(fw)) { // focus was on old page
// look for the best focus widget we can find
QWidget *p = w->focusWidget();
if (!p) {
// 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(w) && i->isEnabled()
&& w->isAncestorOf(i)) {
p = i;
break;
}
}
}
if (p)
p->setFocus();
} else {
// the focus wasn't on the old page, so we have to ensure focus doesn't go to
// the widget in the page that last had focus when we show the page again.
QWidget *oldfw = topWidget->focusWidget();
if (oldfw)
oldfw->clearFocus();
}
}
if (isVisible()) {
emit aboutToShow(w);
int i = id(w);
if (i != -1)
emit aboutToShow(i);
}
topWidget = w;
QObjectList c = children();
for (int i = 0; i < c.size(); ++i) {
QObject * o = c.at(i);
if (o->isWidgetType() && o != w && o != invisible)
static_cast<QWidget *>(o)->hide();
}
w->setGeometry(invisible->geometry());
w->show();
}
示例7: raiseWidget
void QWidgetStack::raiseWidget( QWidget *w )
{
if ( !w || w == invisible || w->parent() != this || w == topWidget )
return;
if ( id(w) == -1 )
addWidget( w );
if ( !isVisible() ) {
topWidget = w;
return;
}
if (w->maximumSize().width() < invisible->width()
|| w->maximumSize().height() < invisible->height())
invisible->setBackgroundMode(backgroundMode());
else if (invisible->backgroundMode() != NoBackground)
invisible->setBackgroundMode(NoBackground);
if ( invisible->isHidden() ) {
invisible->setGeometry( contentsRect() );
invisible->lower();
invisible->show();
QApplication::sendPostedEvents( invisible, QEvent::ShowWindowRequest );
}
// try to move focus onto the incoming widget if focus
// was somewhere on the outgoing widget.
if ( topWidget ) {
QWidget * fw = focusWidget();
QWidget* p = fw;
while ( p && p != topWidget )
p = p->parentWidget();
if ( p == topWidget ) { // focus was on old page
if ( !focusWidgets )
focusWidgets = new QPtrDict<QWidget>( 17 );
focusWidgets->replace( topWidget, fw );
fw->clearFocus();
// look for the best focus widget we can find
// best == what we had (which may be deleted)
fw = focusWidgets->take( w );
if ( isChildOf( fw, w ) ) {
fw->setFocus();
} else {
// second best == first child widget in the focus chain
QFocusData *f = focusData();
QWidget* home = f->home();
QWidget *i = home;
do {
if ( ( ( i->focusPolicy() & TabFocus ) == TabFocus )
&& !i->focusProxy() && i->isVisibleTo(w) && i->isEnabled() ) {
p = i;
while ( p && p != w )
p = p->parentWidget();
if ( p == w ) {
i->setFocus();
break;
}
}
i = f->next();
} while( i != home );
}
}
}
if ( isVisible() ) {
emit aboutToShow( w );
int i = id( w );
if ( i != -1 )
emit aboutToShow( i );
}
topWidget = w;
const QObjectList * c = children();
QObjectListIt it( *c );
QObject * o;
while( (o=it.current()) != 0 ) {
++it;
if ( o->isWidgetType() && o != w && o != invisible )
((QWidget *)o)->hide();
}
w->setGeometry( invisible->geometry() );
w->show();
}