本文整理汇总了C++中QWidget::clearFocus方法的典型用法代码示例。如果您正苦于以下问题:C++ QWidget::clearFocus方法的具体用法?C++ QWidget::clearFocus怎么用?C++ QWidget::clearFocus使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QWidget
的用法示例。
在下文中一共展示了QWidget::clearFocus方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: changedTabPanel
void PrefsDialog::changedTabPanel(int index)
{
// this all feels a bit hacky, but seems to keep things tidy on Mac OS X at least
QWidget *page = tabWidget->widget(index);
page->clearFocus();
switch (index) {
case 0: // General
if (page->focusWidget() != NULL)
page->focusWidget()->clearFocus();
break;
case 1: // Editor
editorFont->setFocus();
editorFont->lineEdit()->selectAll();
break;
case 2: // Preview
scale->setFocus();
scale->selectAll();
break;
case 3: // Typesetting
binPathList->setFocus();
break;
case 4: // Script
if (page->focusWidget() != NULL)
page->focusWidget()->clearFocus();
break;
}
}
示例2: 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);
}
示例3: clearChildWidgetFocus
void PropertyWindow::clearChildWidgetFocus()
{
// сбрасываем фокус с текущего активного виджета, если он находится в окне свойств
QWidget *widgetWithFocus = QApplication::focusWidget();
for (QWidget *widget = widgetWithFocus; widget != NULL; widget = widget->parentWidget())
if (widget == this)
widgetWithFocus->clearFocus();
}
示例4: unfocus
void ChromeClientQt::unfocus()
{
if (!m_webPage)
return;
QWidget* view = m_webPage->view();
if (!view)
return;
view->clearFocus();
}
示例5: focusWindowChanged
void QWindowContainer::focusWindowChanged(QWindow *focusWindow)
{
Q_D(QWindowContainer);
d->oldFocusWindow = focusWindow;
if (focusWindow == d->window) {
QWidget *widget = QApplication::focusWidget();
if (widget)
widget->clearFocus();
}
}
示例6: hideInput
void SyszuxIM::hideInput() //隐藏输入法槽函数
{
QWidget *currentWidget = new QWidget;
QWidget *parentWidget = new QWidget;
currentWidget = QApplication::focusWidget();
parentWidget = currentWidget->parentWidget();
if ( 0 != widgetMoveY) {
parentWidget->move(0,parentWidget->pos().ry() + widgetMoveY);
widgetMoveY = 0;
}
currentWidget->clearFocus();
}
示例7: MoveRoadSectionCommand
void
SignalSettings::on_sSpinBox_editingFinished()
{
if (valueChanged_)
{
MoveRoadSectionCommand *command = new MoveRoadSectionCommand(signal_, ui->sSpinBox->value(), RSystemElementRoad::DRS_SignalSection);
getProjectSettings()->executeCommand(command);
valueChanged_ = false;
QWidget * focusWidget = QApplication::focusWidget();
if (focusWidget)
{
focusWidget->clearFocus();
}
}
}
示例8: QString
void
ObjectSettings::onEditingFinished()
{
if (valueChanged_)
{
QString filename = ui->nameBox->text();
QString newId = object_->getId();
RSystemElementRoad * road = object_->getParentRoad();
if (filename != object_->getName())
{
QStringList parts = object_->getId().split("_");
if (parts.size() > 2)
{
newId = QString("%1_%2_%3").arg(parts.at(0)).arg(parts.at(1)).arg(filename);
}
else
{
newId = road->getRoadSystem()->getUniqueId(object_->getId(), filename);
}
}
double repeatLength = ui->repeatLengthSpinBox->value();
if (repeatLength > road->getLength() - ui->repeatSSpinBox->value())
{
repeatLength = road->getLength() - ui->repeatSSpinBox->value();
}
SetObjectPropertiesCommand *command = new SetObjectPropertiesCommand(object_, newId, filename, ui->typeBox->text(), ui->tSpinBox->value(), ui->zOffsetSpinBox->value(),
ui->validLengthSpinBox->value(), (Object::ObjectOrientation)ui->orientationComboBox->currentIndex(), ui->lengthSpinBox->value(), ui->widthSpinBox->value(), ui->radiusSpinBox->value(), ui->heightSpinBox->value(), ui->hdgSpinBox->value(),
ui->pitchSpinBox->value(), ui->rollSpinBox->value(), ui->poleCheckBox->isChecked(), ui->repeatSSpinBox->value(), repeatLength, ui->repeatDistanceSpinBox->value(), ui->textureLineEdit->text());
getProjectSettings()->executeCommand(command);
valueChanged_ = false;
QWidget * focusWidget = QApplication::focusWidget();
if (focusWidget)
{
focusWidget->clearFocus();
}
}
}
示例9: MoveRoadSectionCommand
void
ObjectSettings::updateS(double s)
{
MoveRoadSectionCommand *moveSectionCommand = new MoveRoadSectionCommand(object_, s, RSystemElementRoad::DRS_ObjectSection);
if (moveSectionCommand->isValid())
{
getProjectData()->getUndoStack()->beginMacro(QObject::tr("Change Start Values"));
getProjectSettings()->executeCommand(moveSectionCommand);
SetObjectPropertiesCommand *setPropertiesCommand = new SetObjectPropertiesCommand(object_, object_->getId(), object_->getName(), object_->getType(), object_->getT(), object_->getzOffset(), object_->getValidLength(), object_->getOrientation(), object_->getLength(), object_->getWidth(), object_->getRadius(), object_->getHeight(), object_->getHeading(), object_->getPitch(), object_->getRoll(), object_->getPole(), object_->getSStart(), object_->getRepeatLength(), object_->getRepeatDistance(), object_->getTextureFileName());
getProjectSettings()->executeCommand(setPropertiesCommand);
getProjectData()->getUndoStack()->endMacro();
}
valueChanged_ = false;
QWidget * focusWidget = QApplication::focusWidget();
if (focusWidget)
{
focusWidget->clearFocus();
}
}
示例10: 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();
}
示例11: 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();
}
示例12: 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();
}
示例13: clearFocus
void QWidgetProto::clearFocus()
{
QWidget *item = qscriptvalue_cast<QWidget*>(thisObject());
if (item)
item->clearFocus();
}
示例14: if
void
SignalSettings::onEditingFinished()
{
if (valueChanged_)
{
double t = ui->tSpinBox->value();
int fromLane = ui->fromLaneSpinBox->value();
int toLane = ui->toLaneSpinBox->value();
if (toLane > fromLane)
{
toLane = fromLane;
}
if (signal_->getType() != 293)
{
if (((t < 0) && ((fromLane > 0) || (fromLane < signal_->getParentRoad()->getLaneSection(signal_->getSStart())->getRightmostLaneId()))) || ((t > 0) && ((fromLane < 0) || (fromLane > signal_->getParentRoad()->getLaneSection(signal_->getSStart())->getLeftmostLaneId()))))
{
fromLane = signal_->getParentRoad()->getValidLane(signal_->getSStart(), t);
}
if (((t < 0) && ((toLane > 0) || (toLane < signal_->getParentRoad()->getLaneSection(signal_->getSStart())->getRightmostLaneId()))) || ((t > 0) && ((toLane < 0) || (toLane > signal_->getParentRoad()->getLaneSection(signal_->getSStart())->getLeftmostLaneId()))))
{
toLane = signal_->getParentRoad()->getValidLane(signal_->getSStart(), t);
}
}
else
{
if ((fromLane != signal_->getValidFromLane()) || (toLane != signal_->getValidToLane()))
{
if ((fromLane >= 0) && (toLane >= 0) && (t < 0))
{
LaneSection *laneSection = signal_->getParentRoad()->getLaneSection(signal_->getSStart());
t = laneSection->getLaneSpanWidth(fromLane, toLane, signal_->getSStart());
}
else if ((fromLane <= 0) && (toLane <= 0) && (t > 0))
{
LaneSection *laneSection = signal_->getParentRoad()->getLaneSection(signal_->getSStart());
t = -laneSection->getLaneSpanWidth(fromLane, toLane, signal_->getSStart());
}
}
if (fromLane < signal_->getParentRoad()->getLaneSection(signal_->getSStart())->getRightmostLaneId())
{
fromLane = signal_->getParentRoad()->getLaneSection(signal_->getSStart())->getRightmostLaneId();
}
else if (fromLane > signal_->getParentRoad()->getLaneSection(signal_->getSStart())->getLeftmostLaneId())
{
fromLane = signal_->getParentRoad()->getLaneSection(signal_->getSStart())->getLeftmostLaneId();
}
if (toLane < signal_->getParentRoad()->getLaneSection(signal_->getSStart())->getRightmostLaneId())
{
toLane = signal_->getParentRoad()->getLaneSection(signal_->getSStart())->getRightmostLaneId();
}
else if (toLane > signal_->getParentRoad()->getLaneSection(signal_->getSStart())->getLeftmostLaneId())
{
toLane = signal_->getParentRoad()->getLaneSection(signal_->getSStart())->getLeftmostLaneId();
}
}
double crossingProb = 0.0;
double resetTime = 0.0;
if (ui->crossingProbLabel->isEnabled())
{
crossingProb = ui->crossingSpinBox->value();
resetTime = ui->resetTimeSpinBox->value();
}
SetSignalPropertiesCommand *command = new SetSignalPropertiesCommand(signal_, signal_->getId(), signal_->getName(), t, ui->dynamicCheckBox->isChecked(), (Signal::OrientationType)ui->orientationComboBox->currentIndex(), ui->zOffsetSpinBox->value(), ui->countryBox->text(), ui->typeSpinBox->value(), ui->subclassLineEdit->text(), ui->subtypeSpinBox->value(), ui->valueSpinBox->value(), ui->hOffsetSpinBox->value(), ui->pitchSpinBox->value(), ui->rollSpinBox->value(), ui->poleCheckBox->isChecked(), ui->sizeComboBox->currentIndex() + 1, fromLane, toLane, crossingProb, resetTime, NULL);
getProjectSettings()->executeCommand(command);
valueChanged_ = false;
QWidget * focusWidget = QApplication::focusWidget();
if (focusWidget)
{
focusWidget->clearFocus();
}
}
}