Results 1 to 10 of 10

Thread: simultaneous use of ctrl key along with mouse press event.

  1. #1
    Join Date
    Jan 2010
    Location
    Bhubaneswar, Odisha
    Posts
    25
    Thanks
    3
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Post simultaneous use of ctrl key along with mouse press event.

    Hi all

    How can i select multiple objects by pressing CTRL key along with mouse left button as we do in windows environment.

    my configuration:
    os : windows xp
    qt : 4.7.0

    thanks.

  2. #2
    Join Date
    Feb 2011
    Posts
    354
    Thanks
    17
    Thanked 27 Times in 24 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Windows

    Default Re: simultaneous use of ctrl key along with mouse press event.

    setSelectionMode(QAbstractItemView::ExtendedSelect ion)

  3. #3
    Join Date
    Jan 2010
    Location
    Bhubaneswar, Odisha
    Posts
    25
    Thanks
    3
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: simultaneous use of ctrl key along with mouse press event.

    Thanks for ur reply.

    But what I am doing is application for touch device it consist of label, button, spinbox etc.
    What u suggest is, it will select icons only if I am not wrong.

    What I want is "touch2.jpeg" but I am getting "touch1.jpeg". These two are attached bellow.
    So please suggest me how and where i should store different types of widget so that if I select copy and then paste these object on label it will paste all objects. or is there any container Qt is providing to store and retrieve multiple objects of different type.

    Thanks

    touch1.JPG touch2.JPG

  4. #4
    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: simultaneous use of ctrl key along with mouse press event.

    So what exactly is your problem? Selecting items? Copying them? Pasting them?
    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.


  5. #5
    Join Date
    Jan 2010
    Location
    Bhubaneswar, Odisha
    Posts
    25
    Thanks
    3
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: simultaneous use of ctrl key along with mouse press event.

    multiple selection.

  6. #6
    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: simultaneous use of ctrl key along with mouse press event.

    Are you using graphics view or item views? And what have you tried so far?
    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.


  7. #7
    Join Date
    Jan 2010
    Location
    Bhubaneswar, Odisha
    Posts
    25
    Thanks
    3
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: simultaneous use of ctrl key along with mouse press event.

    What i am using is label and drawing image on it and for object that shows selected i.e. the object surrounded by small squares are also labels used for resizing and to show that this object is selected.

    Next what i want is if I select multiple object using CTRL key and mouse press it will select that many object for copy paste purpose.

    To achieve this i am checking " if (event->KeyPress == Qt::CTRL) " withing mousePressEvent. But i'm not getting the desired result.

    thanks.

  8. #8
    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: simultaneous use of ctrl key along with mouse press event.

    Eeeeeeemmmmm.... you really shouldn't be doing it this way. That's probably the worst possible approach to the problem. Doing it the way you want will be a load of (totally needless) work. Use either Graphics View or Item Views (whichever fits your usecase better).
    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.


  9. The following user says thank you to wysota for this useful post:

    vinod sharma (27th February 2012)

  10. #9
    Join Date
    Jan 2010
    Location
    Bhubaneswar, Odisha
    Posts
    25
    Thanks
    3
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: simultaneous use of ctrl key along with mouse press event.

    thank you for sharing knowledge.

  11. #10
    Join Date
    Sep 2011
    Location
    Manchester
    Posts
    538
    Thanks
    3
    Thanked 106 Times in 103 Posts
    Qt products
    Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: simultaneous use of ctrl key along with mouse press event.

    Quote Originally Posted by vinod sharma View Post
    To achieve this i am checking " if (event->KeyPress == Qt::CTRL) " withing mousePressEvent. But i'm not getting the desired result.
    I agree with wysota, but even then above line will not work, you should be doing if(event->modifiers() & Qt::CTRL ) instead.

Similar Threads

  1. Replies: 2
    Last Post: 1st January 2011, 00:16
  2. QGraphicsview and mouse press event
    By eva2002 in forum Qt Programming
    Replies: 6
    Last Post: 26th January 2010, 05:04
  3. Mouse press event in a QGraphicsScene
    By Lykurg in forum Qt Programming
    Replies: 3
    Last Post: 19th June 2009, 10:28
  4. Mouse press event detection
    By A.H.M. Mahfuzur Rahman in forum Qt Programming
    Replies: 1
    Last Post: 14th June 2009, 13:08
  5. Checking for key press on mouse event
    By Cruz in forum Newbie
    Replies: 1
    Last Post: 24th January 2009, 18:18

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.