PDA

View Full Version : simultaneous use of ctrl key along with mouse press event.



vinod sharma
24th February 2012, 07:50
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.

mentalmushroom
24th February 2012, 08:21
setSelectionMode(QAbstractItemView::ExtendedSelect ion)

vinod sharma
27th February 2012, 08:41
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

7437 7438

wysota
27th February 2012, 10:17
So what exactly is your problem? Selecting items? Copying them? Pasting them?

vinod sharma
27th February 2012, 10:50
multiple selection.

wysota
27th February 2012, 10:58
Are you using graphics view or item views? And what have you tried so far?

vinod sharma
27th February 2012, 11:41
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.

wysota
27th February 2012, 12:01
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).

vinod sharma
27th February 2012, 12:14
thank you for sharing knowledge.

Spitfire
28th February 2012, 11:09
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.