Results 1 to 3 of 3

Thread: QListWidget activate all selected items

  1. #1
    Join Date
    May 2013
    Posts
    321
    Thanks
    9
    Thanked 8 Times in 8 Posts
    Qt products
    Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Exclamation QListWidget activate all selected items

    Hi,
    QListWidget has a behabior for the activation key but that only activate the last selected and not all selected items.
    I tried to find the activation key sequence in the qt doc to overwrite the action but nothing found.
    How achieve that correctly ?
    Thanks

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: QListWidget activate all selected items

    Reimplement keyPressEvent() and perform activation for each of the items.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  3. #3
    Join Date
    May 2013
    Posts
    321
    Thanks
    9
    Thanked 8 Times in 8 Posts
    Qt products
    Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: QListWidget activate all selected items

    This is what I did at the end, I did like that :
    Qt Code:
    1. virtual void keyPressEvent( QKeyEvent* event ) override
    2. {
    3. // Activate all selected items when enter or return.
    4. if( ( event->key() == Qt::Key_Enter ) || ( event->key() == Qt::Key_Return ) )
    5. {
    6. // Call itemActivated for each item needed.
    7. ...
    8. event->accept();
    9. return;
    10. }
    11.  
    12. // Alphanumeric keys.
    13. if( event->text().isEmpty() == false )
    14. QListWidget::keyPressEvent( event );
    15. }
    To copy to clipboard, switch view to plain text mode 
    That works good but the Qt doc says mac uses another key, but maybe enter and return works good for all plateform at the end.
    If I press multiple time one alphanumeric key, the action is stopped, I have no answer why.
    Last edited by Alundra; 21st January 2016 at 00:21.

Similar Threads

  1. Replies: 0
    Last Post: 25th April 2014, 08:59
  2. QListWidget, how to copy selected items to clipboard
    By mnrao1230 in forum Qt Programming
    Replies: 3
    Last Post: 24th February 2012, 10:54
  3. Replies: 2
    Last Post: 1st April 2011, 09:32
  4. qlistwidget count of selected items
    By tpf80 in forum Newbie
    Replies: 4
    Last Post: 10th December 2009, 13:31
  5. How to set selected item of a QListWidget?
    By Lawand in forum Qt Programming
    Replies: 9
    Last Post: 5th April 2009, 11:23

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.