Hi,
i am trying to operate the listview itesm through keyboard focus, its not moving.. can you folks suggest where i am wrong.
if i click on the listview from mouse, listview is gaining the focus. i dont no what is wrong.
class Newlist : public QWidget
{
public:
Newlist(QWidget *parent = 0);
~Newlist(){};
public:
QListView *list;
QStringListModel *model;
};
Newlist::Newlist(QWidget *parent)
: QWidget(parent)
{
list = new QListView(this);
list->setViewMode(QListView::ListMode);
list->setSelectionMode(QAbstractItemView::SingleSelection);
list->setMinimumSize(300,500);
model = new QStringListModel(this);
QStringList strlist;
strlist<<"Test"<<"fest"<<"mest";
list->setModel(model);
model->setStringList(strlist);
QModelIndex index = model->index(1,0);
list->setCurrentIndex(index);
QVBoxLayout *layout = new QVBoxLayout(this);
layout->addWidget(list);
setLayout(layout);
list->setFocus();
}
class Test : public QMainWindow
{
public:
Test(QWidget *parent = 0);
~Test(){};
private:
Mylistview *newlist;
QVBoxLayout *layout;
QStackedWidget *stack;
};
Test::Test(QWidget *parent)
: QMainWindow(parent)
{
layout = new QVBoxLayout();
newlist = new Mylistview();
stack = new QStackedWidget(this);
stack->addWidget(newlist);
this->setCentralWidget(stack);
}
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
Test test;
test.showMaximized();
return a.exec();
}
Thanks in advance