本文整理汇总了C++中QWidget::isFocusEnabled方法的典型用法代码示例。如果您正苦于以下问题:C++ QWidget::isFocusEnabled方法的具体用法?C++ QWidget::isFocusEnabled怎么用?C++ QWidget::isFocusEnabled使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QWidget
的用法示例。
在下文中一共展示了QWidget::isFocusEnabled方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: displayAccessKeys
void KKbdAccessExtensions::displayAccessKeys()
{
// Build a list of valid access keys that don't collide with shortcuts.
QString availableAccessKeys = "ABCDEFGHIJKLMNOPQRSTUVWXYZ01234567890";
QPtrList<KXMLGUIClient> allClients = d->mainWindow->factory()->clients();
QPtrListIterator<KXMLGUIClient> it( allClients );
KXMLGUIClient *client;
while( (client=it.current()) !=0 )
{
++it;
KActionPtrList actions = client->actionCollection()->actions();
for (int j = 0; j < (int)actions.count(); j++) {
KAction* action = actions[j];
KShortcut sc = action->shortcut();
for (int i = 0; i < (int)sc.count(); i++) {
KKeySequence seq = sc.seq(i);
if (seq.count() == 1) {
QString s = seq.toString();
if (availableAccessKeys.contains(s))
availableAccessKeys.remove(s);
}
}
}
}
// Find all visible, focusable widgets and create a QLabel for each. Don't exceed
// available list of access keys.
QWidgetList* allWidgets = kapp->allWidgets();
QWidget* widget = allWidgets->first();
int accessCount = 0;
int maxAccessCount = availableAccessKeys.length();
int overlap = 20;
QPoint prevGlobalPos = QPoint(-overlap, -overlap);
while (widget && (accessCount < maxAccessCount)) {
if (widget->isVisible() && widget->isFocusEnabled() ) {
QRect r = widget->rect();
QPoint p(r.x(), r.y());
// Don't display an access key if within overlap pixels of previous one.
QPoint globalPos = widget->mapToGlobal(p);
QPoint diffPos = globalPos - prevGlobalPos;
if (diffPos.manhattanLength() > overlap) {
accessCount++;
QLabel* lab=new QLabel(widget, "", widget, 0, Qt::WDestructiveClose);
lab->setPalette(QToolTip::palette());
lab->setLineWidth(2);
lab->setFrameStyle(QFrame::Box | QFrame::Plain);
lab->setMargin(3);
lab->adjustSize();
lab->move(p);
if (!d->accessKeyLabels) {
d->accessKeyLabels = new QPtrList<QLabel>;
d->accessKeyLabels->setAutoDelete(true);
}
d->accessKeyLabels->append(lab);
prevGlobalPos = globalPos;
}
}
widget = allWidgets->next();
}
if (accessCount > 0) {
// Sort the access keys from left to right and down the screen.
QValueList<KSortedLabel> sortedLabels;
for (int i = 0; i < accessCount; i++)
sortedLabels.append(KSortedLabel(d->accessKeyLabels->at(i)));
qHeapSort( sortedLabels );
// Assign access key labels.
for (int i = 0; i < accessCount; i++) {
QLabel* lab = sortedLabels[i].label();
QChar s = availableAccessKeys[i];
lab->setText(s);
lab->adjustSize();
lab->show();
}
}
}