本文整理汇总了C++中QWidget::hasFocus方法的典型用法代码示例。如果您正苦于以下问题:C++ QWidget::hasFocus方法的具体用法?C++ QWidget::hasFocus怎么用?C++ QWidget::hasFocus使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QWidget
的用法示例。
在下文中一共展示了QWidget::hasFocus方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: fixFocus
void QGroupBox::fixFocus()
{
QFocusData * fd = focusData();
QWidget * orig = fd->home();
QWidget * best = 0;
QWidget * candidate = 0;
QWidget * w = orig;
do {
QWidget * p = w;
while( p && p != this && !p->isTopLevel() )
p = p->parentWidget();
if ( p == this && ( w->focusPolicy() & TabFocus ) == TabFocus
&& w->isVisibleTo(this) ) {
if ( w->hasFocus()
#ifndef QT_NO_RADIOBUTTON
|| ( !best && ::qt_cast<QRadioButton*>(w)
&& ((QRadioButton*)w)->isChecked() )
#endif
)
// we prefer a checked radio button or a widget that
// already has focus, if there is one
best = w;
else if ( !candidate )
// but we'll accept anything that takes focus
candidate = w;
}
w = fd->next();
} while( w != orig );
if ( best )
best->setFocus();
else if ( candidate )
candidate->setFocus();
}
示例2: setCurrentIndex
void TabWidget::setCurrentIndex(int tabIndex)
{
QWidget *w = currentWidget();
const int current = (isTreeModeEnabled() && w != NULL && w->isHidden()) ? -1 : currentIndex();
if (tabIndex == current)
return;
if (tabIndex != -1) {
m_stackedWidget->setCurrentIndex(tabIndex);
w = currentWidget();
if (w == NULL)
return;
w->show();
if (isTreeModeEnabled() ? m_tabTree->hasFocus() : m_tabBar->hasFocus())
w->setFocus();
if ( isTreeModeEnabled() )
m_tabTree->setCurrentTabIndex(tabIndex);
else
m_tabBar->setCurrentIndex(tabIndex);
} else if (w != NULL) {
if (w->hasFocus())
isTreeModeEnabled() ? m_tabTree->setFocus() : m_tabBar->setFocus();
w->hide();
}
emit currentChanged(tabIndex, current);
}
示例3: eventuallyDoFocus
void OutputWidget::eventuallyDoFocus()
{
QWidget* widget = currentWidget();
if( focusOnSelect->isChecked() && !widget->hasFocus() ) {
widget->setFocus( Qt::OtherFocusReason );
}
}
示例4: eventFilter
bool ShortcutOverrideFilter::eventFilter(QObject* object, QEvent* event) {
QWidget* widget = qobject_cast<QWidget*>(object);
int i;
if (!widget)
return false;
// If a key sequence is bound to a shortcut, Qt dispatches a ShortcutOverride
// event event instead of a KeyPress, if it is handled, then the normal keypress
// event will follow, otherwise the shortcut is activated
if (event->type() == QEvent::ShortcutOverride) {
QKeyEvent *keyEvent = static_cast<QKeyEvent*>(event);
QKeySequence pressed(keyEvent->key() + keyEvent->modifiers());
if (keyEvent->key() == Qt::Key_Escape) {
if (widget->hasFocus()) {
if (qobject_cast<QLineEdit*>(object) || qobject_cast<QComboBox*>(object)) {
event->accept();
return true;
}
}
} else {
for (i=0; i<overrides.size(); i++) {
if (pressed == overrides.at(i)) {
event->accept();
return true;
}
}
}
}
return false;
}
示例5: selectRow
void FLDataTable::selectRow(int r, int c)
{
if (!cursor_ || !cursor_->metadata())
return ;
if (r < 0) {
if (cursor_->isValid()) {
rowSelected = cursor_->at();
colSelected = currentColumn();
} else {
rowSelected = 0;
colSelected = 0;
}
} else {
rowSelected = r;
colSelected = c;
}
QObject *snd = const_cast<QObject *>(sender());
if (!snd || (snd && !snd ->isA("FLSqlCursor"))) {
QWidget *sndw = ::qt_cast<QWidget *>(snd);
if (sndw) {
if (!sndw->hasFocus() || !sndw->isVisible()) {
setCurrentCell(rowSelected, colSelected);
return ;
}
}
if (numRows() != cursor_->size())
setNumRows(cursor_->size());
cursor_->seek(rowSelected);
}
setCurrentCell(rowSelected, colSelected);
}
示例6: hasFocus
bool QWidgetProto::hasFocus() const
{
QWidget *item = qscriptvalue_cast<QWidget*>(thisObject());
if (item)
return item->hasFocus();
return false;
}
示例7: state
/*! \reimp */
QAccessible::State QAccessibleWidget::state(int child) const
{
if (child)
return Normal;
QAccessible::State state = Normal;
QWidget *w = widget();
if (w->testAttribute(Qt::WA_WState_Visible) == false)
state |= Invisible;
if (w->focusPolicy() != Qt::NoFocus)
state |= Focusable;
if (w->hasFocus())
state |= Focused;
if (!w->isEnabled())
state |= Unavailable;
if (w->isWindow()) {
if (w->windowFlags() & Qt::WindowSystemMenuHint)
state |= Movable;
if (w->minimumSize() != w->maximumSize())
state |= Sizeable;
}
return state;
}
示例8: handleProgressFinished
bool QWebFramePrivate::handleProgressFinished(QPoint *localPos)
{
QWidget *view = q->page()->view();
if (!view || !localPos)
return false;
*localPos = view->mapFromGlobal(QCursor::pos());
return view->hasFocus() && view->rect().contains(*localPos);
}
示例9: toggleComandLineFocus
void MainWindow::toggleComandLineFocus()
{
QWidget *cmd = cmdLine();
if(cmd->hasFocus()) {
QWidget *editor = mEditors->currentEditor();
if(editor) editor->setFocus(Qt::OtherFocusReason);
}
else
cmd->setFocus(Qt::OtherFocusReason);
}
示例10: postProgressFinishedNotification
void FrameLoaderClientQt::postProgressFinishedNotification()
{
// send a mousemove event to
// (1) update the cursor to change according to whatever is underneath the mouse cursor right now
// (2) display the tool tip if the mouse hovers a node which has a tool tip
if (m_frame && m_frame->eventHandler() && m_webFrame->page()) {
QWidget* view = m_webFrame->page()->view();
if (view && view->hasFocus()) {
QPoint localPos = view->mapFromGlobal(QCursor::pos());
if (view->rect().contains(localPos)) {
QMouseEvent event(QEvent::MouseMove, localPos, Qt::NoButton, Qt::NoButton, Qt::NoModifier);
m_frame->eventHandler()->mouseMoved(PlatformMouseEvent(&event, 0));
}
}
}
if (m_webFrame && m_frame->page())
emit loadFinished(m_loadError.isNull());
}
示例11: state
/*! \reimp */
QAccessible::State QAccessibleWidget::state() const
{
QAccessible::State state;
QWidget *w = widget();
if (w->testAttribute(Qt::WA_WState_Visible) == false)
state.invisible = true;
if (w->focusPolicy() != Qt::NoFocus)
state.focusable = true;
if (w->hasFocus())
state.focused = true;
if (!w->isEnabled())
state.disabled = true;
if (w->isWindow()) {
if (w->windowFlags() & Qt::WindowSystemMenuHint)
state.movable = true;
if (w->minimumSize() != w->maximumSize())
state.sizeable = true;
if (w->isActiveWindow())
state.active = true;
}
return state;
}