Results 1 to 6 of 6

Thread: QListWidget is slow when an item is clicked in the list

  1. #1
    Join Date
    Oct 2014
    Posts
    13
    Thanks
    1
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Post QListWidget is slow when an item is clicked in the list

    Hi all,

    I have a Qlistwidget with which i create a list consisting of 2 items. the contents for the list are displayed in a QTextbrowser placed beside it. I set the current row to first item so that by defaults it points to the first element. When i click on the 2nd item, It takes almost around 5 seconds to appear in the textbrowser. What could be the issue here?

    This is my code:

    _list = new QListWidget(this);
    QListWidgetItem *item1 = new QListWidgetItem;
    item1->setText("List Item 1");
    _list->insertItem(0, item1);
    QListWidgetItem *item2 = new QListWidgetItem;
    item2->setText("List Item 2");
    _list->insertItem(1, item2);
    _list->setSelectionMode(QAbstractItemView::SingleSelecti on);

    CONNECT(_list->selectionModel(),
    SIGNAL(selectionChanged(QItemSelection,QItemSelect ion)),
    SLOT(onFocusChanged()));
    _list->setCurrentRow(0, QItemSelectionModel::SelectCurrent);

  2. #2
    Join Date
    Jan 2008
    Location
    Poland
    Posts
    687
    Thanks
    4
    Thanked 140 Times in 132 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: QListWidget is slow when an item is clicked in the list

    I do not see any code with QTextBrowser here. I'm guessig that it's used in onFocusChanged() so you should show us this code too.
    I would like to be a "Guru"

    Useful hints (try them before asking):
    1. Use Qt Assistant
    2. Search the forum

    If you haven't found solution yet then create new topic with smart question.

  3. #3
    Join Date
    Oct 2014
    Posts
    13
    Thanks
    1
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default Re: QListWidget is slow when an item is clicked in the list

    _helpBrowser = new QTextBrowser(this);


    void focusChanged()
    {
    QListWidgetItem* const selectedItem = _list->selectedItems()[0];

    if (_list->row(selectedItem) == 0)
    {
    // Show something
    }
    else
    {
    // show something
    }
    }

  4. #4
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: QListWidget is slow when an item is clicked in the list

    And you are sure that the delay you are seeing is not caused by the // show something part?

    Cheers,
    _

  5. #5
    Join Date
    Oct 2014
    Posts
    13
    Thanks
    1
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default Re: QListWidget is slow when an item is clicked in the list

    Well.. May be it could be because of that.
    Thanks..

  6. #6
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: QListWidget is slow when an item is clicked in the list

    Quote Originally Posted by sRB View Post
    Well.. May be it could be because of that.
    Thanks..
    Well, you have not posted any of that code, so we can only assume that you have checked that it is not the cause.

    Cheers,
    _

Similar Threads

  1. Replies: 4
    Last Post: 14th June 2012, 23:33
  2. Replies: 3
    Last Post: 12th February 2012, 23:00
  3. Replies: 8
    Last Post: 21st May 2010, 11:26
  4. QListWidget and takeItem() slow
    By deca5423 in forum Qt Programming
    Replies: 5
    Last Post: 26th November 2009, 15:42
  5. QListWidget clicked signal
    By asieriko in forum Qt Programming
    Replies: 12
    Last Post: 10th August 2007, 15:37

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.