×

Discussion Board

Results 1 to 3 of 3
  1. #1
    Registered User
    Join Date
    May 2010
    Posts
    1

    QListWidget Problems in Symbian S60 HELP!

    I'm coding a qt for symbian application for about a month. I have such problem for help:

    1.you have to press the select button of the mobile phone, then the QListWidget will get the focus, you can then press the up button and down button to move the focus of the QListWidgetItem. How to set the focus so I just use the up/down key to move the focus directly?
    2.The QLineEdit will "eat" the password you have entered, why?

    I will lose my job if these can't be solved. Best wishes for the helper!

  2. #2
    Nokia Developer Moderator
    Join Date
    Oct 2009
    Posts
    4,326

    Re: QListWidget Problems in Symbian S60 HELP!

    Quote Originally Posted by tearsofphoenix View Post
    1.you have to press the select button of the mobile phone, then the QListWidget will get the focus, you can then press the up button and down button to move the focus of the QListWidgetItem. How to set the focus so I just use the up/down key to move the focus directly?
    Call setFocus for QListWidget
    http://doc.qt.nokia.com/4.6/qwidget.html#setFocus
    However, here might be something Symbian specific.

    Quote Originally Posted by tearsofphoenix View Post
    2.The QLineEdit will "eat" the password you have entered, why?
    Probably because of echoMode, however, by default it's QLineEdit::Normal
    http://doc.qt.nokia.com/4.6/qlineedi...#echoMode-prop

  3. #3
    Registered User
    Join Date
    Mar 2010
    Posts
    53

    Re: QListWidget Problems in Symbian S60 HELP!

    Hi tearsofphoenix!

    1.you have to press the select button of the mobile phone, then the QListWidget will get the focus, you can then press the up button and down button to move the focus of the QListWidgetItem. How to set the focus so I just use the up/down key to move the focus directly?
    I used QListView but I hope it helped you.
    I using eventFilter with ListView

    Code:
    ui.feedsView->installEventFilter(this);
    Code:
    bool HomeWidget::eventFilter(QObject *obj, QEvent *event)
    {
    	if (obj == ui.feedsView)
    	{
            if (event->type() == QEvent::FocusIn )
    		{				ui.feedsView->selectionModel()->setCurrentIndex(ui.feedsView->model()->index(0,0), QItemSelectionModel::SelectCurrent);
    		}
    		if (event->type() == QEvent::KeyPress)
    		{
    			QKeyEvent *keyEvent = static_cast<QKeyEvent*>(event);
    			QRect itemRect = ui.feedsView->visualRect(ui.feedsView->currentIndex());
    			QSize viewSize = ui.feedsView->viewport()->size();
    			if ( keyEvent->key() == Qt::Key_Down )
    			{
    				if ( itemRect.height() - mySize >= viewSize.height() + this->fontMetrics().height() /2 )
    				{
    					if ( ui.feedsView->verticalScrollBar()->value() + viewSize.height() - this->fontMetrics().height() <= ui.feedsView->verticalScrollBar()->maximum())
    					{						ui.feedsView->verticalScrollBar()->setValue(ui.feedsView->verticalScrollBar()->value() + viewSize.height() - this->fontMetrics().height());
    						mySize += viewSize.height() - this->fontMetrics().height();
    					}
    					else
    					{
    						vSpace = ui.feedsView->verticalScrollBar()->maximum() - ui.feedsView->verticalScrollBar()->value();
    						mySize += ui.feedsView->verticalScrollBar()->maximum() - ui.feedsView->verticalScrollBar()->value();
    						ui.feedsView->verticalScrollBar()->setValue(ui.feedsView->verticalScrollBar()->maximum());
    					}
    					return true;
    				}
    				else
    				{
    					if ( ui.feedsView->currentIndex().row() < (ui.feedsView->model()->rowCount() - 1) )
    					{
    						QModelIndex newIndexDown = ui.feedsView->model()->index(ui.feedsView->currentIndex().row() + 1, ui.feedsView->currentIndex().column());
    						if (newIndexDown.isValid())
    						{
    							ui.feedsView->selectionModel()->setCurrentIndex(ui.feedsView->currentIndex(), QItemSelectionModel::Clear);
    							ui.feedsView->selectionModel()->setCurrentIndex(newIndexDown, QItemSelectionModel::SelectCurrent);
    							mySize = 0;
    						}
    						return true;
    					}
    				}
    			}
    			if ( keyEvent->key() == Qt::Key_Up)
    			{
    				if ( mySize > 0 )
    				{
    					if ( ui.feedsView->verticalScrollBar()->value() == ui.feedsView->verticalScrollBar()->maximum() && vSpace > 0 )
    					{
    						ui.feedsView->verticalScrollBar()->setValue(ui.feedsView->verticalScrollBar()->value()- vSpace);
    						mySize -= vSpace;
    					}
    					else
    					{
    						ui.feedsView->verticalScrollBar()->setValue(ui.feedsView->verticalScrollBar()->value()- viewSize.height() + this->fontMetrics().height());
    						mySize += this->fontMetrics().height() - viewSize.height();			
    					}
    					return true;
    				}
    				else
    				{
    					if (ui.feedsView->currentIndex().row() >0 )
    					{
    						QModelIndex newIndexUp = ui.feedsView->model()->index(ui.feedsView->currentIndex().row() - 1, ui.feedsView->currentIndex().column());
    						if (newIndexUp.isValid() )
    						{							ui.feedsView->selectionModel()->setCurrentIndex(newIndexUp, QItemSelectionModel::SelectCurrent);
    						}
    						return true;
    					}
    				}
    			}
    			if ( keyEvent->key() == Qt::Key_Return || keyEvent->key() == 16842752 )
    			{
    				// Do some thing when item selected
    				return true;
    			}
    		}
    	}
    	return QWidget::eventFilter(obj, event);
    }
    in file .h I definition :
    Code:
    int mySize;    // init = 0 at constructor
    int vSpace;    // init = 0 at constructor
    It does not seem to be standard but it works fine for me, even with the height of the item is much larger than viewsize of device.

    2.The QLineEdit will "eat" the password you have entered, why?
    QLineEdit with echoMode "Password" is bug in 4.6.2. I think you can implement QLineEdit to solve this problem (unfortunately I have not tried, if someone has solved this problem please post your solution on here, thank you very much!)

Similar Threads

  1. Qt for Symbian development resources
    By liuxg in forum [Archived] Qt General ( Qt技术)
    Replies: 55
    Last Post: 2011-01-26, 04:06
  2. Replies: 2
    Last Post: 2009-04-23, 08:25
  3. Python for S60 1.9.3 released
    By tvijayan in forum Symbian
    Replies: 40
    Last Post: 2009-04-03, 15:00
  4. Current Symbian Development Opportunities...!!
    By mobile2004 in forum Symbian
    Replies: 0
    Last Post: 2005-01-17, 17:58
  5. Almost all tools (S60 MIDP SDK B0.1, Nokia S60 SDK Symbian OS v0.3) Crashes
    By alexandershalamov in forum Symbian Tools & SDKs
    Replies: 1
    Last Post: 2002-07-03, 13:44

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •