请让我知道它是否是一种功能行为
我有一个充满项目的列表视图。默认情况下,将选择第 0 项。
如果我尝试使用移动键盘浏览列表,它不会获得焦点 - 相反,我需要使用移动选择键来获得焦点。在此过程中,我的手机左软键更改为“完成”。为什么会出现“完成”菜单?
如何为列表视图提供默认焦点?如何避免左软键显示“完成”?
这是我的代码:
#include "Test_Doco.h"
#include <QtGui>
#include <QApplication>
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
QListView *listui = new QListView();
listui->setSelectionMode(QAbstractItemView::SingleSelection);
listui->viewport()->setFocusPolicy(Qt::WheelFocus);
listui->viewport()->setFocus();
QStandardItemModel* listModel = new QStandardItemModel();
for(int i =0; i<10;i++)
{
QStandardItem *item1 = new QStandardItem("AOL");
listModel->appendRow(item1);
}
QModelIndex index = listModel->index(0,0);
listui->setCurrentIndex(index);
listui->setModel(listModel);
listui->showMaximized();
return a.exec();
}
编辑:我已经更新了代码。请检查一下。
I have a listview filled with items. By default, the 0th item will be selected.
If I try to navigate the list using the mobile keypad, it's not gaining focus - instead I need to use my mobile select key for focus. In this process my mobile left soft key gets changed to “Done”. Why is the "Done" menu appearing?
How do I provide default focus to the listview? And how do I avoid the display of “Done” at left soft key?
Here is my code:
#include "Test_Doco.h"
#include <QtGui>
#include <QApplication>
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
QListView *listui = new QListView();
listui->setSelectionMode(QAbstractItemView::SingleSelection);
listui->viewport()->setFocusPolicy(Qt::WheelFocus);
listui->viewport()->setFocus();
QStandardItemModel* listModel = new QStandardItemModel();
for(int i =0; i<10;i++)
{
QStandardItem *item1 = new QStandardItem("AOL");
listModel->appendRow(item1);
}
QModelIndex index = listModel->index(0,0);
listui->setCurrentIndex(index);
listui->setModel(listModel);
listui->showMaximized();
return a.exec();
}
Edit: I have updated the code. Please check it.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
对于默认焦点,停止调用
listui->viewport()->setFocus();
并调用listui->setFocus()
为其提供焦点。被创建。至于“完成”的显示,我不太确定,但您可能需要发布更多代码来显示您正在创建的对话框。大多数都有一组默认按钮或一个设置为默认的按钮。 “完成”键可能与此有关。正如此处所示,“退出”是显示的软键。
For the default focus, stop calling
listui->viewport()->setFocus();
and calllistui->setFocus()
to give it focus when it is created.As for the display of "Done", I'm not too sure, but you might need to post more code to show the dialog you are creating. Most have a set of default buttons or a button set to default. The "Done" key might be related to that. As seen here "Exit" is the softkey shown.
该问题是关于 Qt 4.6.2 的,该问题已在 Qt 4.6.3 中修复
The issue is w.r.t Qt 4.6.2 and the issue is fixed in Qt 4.6.3