[Qt-interest] what is the mistake in my code

Ramesh ramesh.bs at robosoftin.com
Fri Mar 26 07:29:29 CET 2010


Are you sure..

With out clicking any mouse button you are able to move list items..

I don't think so..

That is at the first instance of launch. please clarify me one  more time

 

From: linux newbie [mailto:linux.newbie79 at gmail.com] 
Sent: Friday, March 26, 2010 4:05 AM
To: Ramesh
Cc: Qt Interest
Subject: Re: [Qt-interest] what is the mistake in my code

 

HI,

 

I just compiled your code and ran it. except for compilation error on
MyListView (which I replaced with Newlist) and things are working fine.

 

At first the focus is on second item and on using up/down arrow keys, i can
able to move it. (without using the mouse at all).

 

May be my understanding about your problem is wrong.

On Thu, Mar 25, 2010 at 11:59 PM, Ramesh <ramesh.bs at robosoftin.com> wrote:

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.

Here is my code,

 

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();
}

 

 

-----------------------------------------------

Robosoft Technologies - Come home to Technology

Disclaimer: This email may contain confidential material. If you were not an
intended recipient, please notify the sender and delete all copies. Emails
to and from our network may be logged and monitored. This email and its
attachments are scanned for virus by our scanners and are believed to be
safe. However, no warranty is given that this email is free of malicious
content or virus.

 


_______________________________________________
Qt-interest mailing list
Qt-interest at trolltech.com
http://lists.trolltech.com/mailman/listinfo/qt-interest

 


-----------------------------------------------
Robosoft Technologies - Come home to Technology

Disclaimer: This email may contain confidential material. If you were not an intended recipient, please notify the sender and delete all copies. Emails to and from our network may be logged and monitored. This email and its attachments are scanned for virus by our scanners and are believed to be safe. However, no warranty is given that this email is free of malicious content or virus.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20100326/521e8b02/attachment.html 


More information about the Qt-interest-old mailing list