MouseEvent in QGridLayout - qt

Trying to implement drag & drop functionality from QGridLayout to QGraphicsScene.
QGridLayout has labels inside of it and I am trying to move them. Is it possible to listen QGridLayout mouse events and get the specific label. With JavaFX this was quite easy to do, but with Qt feels much harder.

Related

How to add a QWidget to a QMenuBar?

I want to add a QLabel to a QMenuBar. I was able to add a QLabel to a QMenu using QActionWidget, but I want the QLabel to sit on the QMenuBar (as a substitute for a QMenu) at the right end of my application. I intend to add a movie to this QLabel in order to simulate a loading circle to indicate that the application is running. How can I add a QWidget to a QMenuBar, or is there some alternative to my ultimate goal? I am using Qt 5.6 with Qt Designer
A widget can be added to the end of the menu-bar with QMenuBar::setCornerWidget.

Finger Scrolling in QGraphicsView in QT?

I want to know whether by default QgraphicsView provides finger scrolling in case of Touch Screen devices or we need to have our own kineticscroller class to achieve it.
I want to have one QListWidget which will have some custom contols added to it and i am adding that list to scene and scene to graphicsview now i want to have finger scroller, whether graphics view will have this property by default ?
Qt provides the QGesture class for handling gesture events. You can inherit from this class and create any gesture you want or use one of the predefined gestures like QPanGesture, QPinchGesture and QSwipeGesture.
Gestures can be enabled for all QWidgets and for QGraphicsScene which is probably what you want in order to move the items in your QGraphicsView. Notice that in most cases you have to explicitly write code about how every gesture will be evaluated.
Gestures can be enabled for instances of QWidget and QGraphicsObject
subclasses.
For an example of gesture programming have a look at the image gestures example. Also have a look at the Gestures Programming article of Qt docs.
If you want multi-touch support in your application have a look at this video from the 2009 DevDays. You may also want to check the QTouchEvent class.

Where should I be catching touch events for painting on a QGraphicsScene?

I want to reimplement the Qt fingerpaint example using my QGraphicsScene rather than a QWidget. However I cannot find an example of this so am unsure if I should capture the events at the view and pass them down to the scene or something else. What is the advice here?
How about the the pinch zoom example? It uses a QGraphicsView as the touch area.

Transparent QLabel in QGraphicsView a good idea?

I'm trying to write a piece of software that allows one to click on a video frame and mark the x,y coordinates of a location in the frame. To design this, I've been wanting to use a QGraphicsView subclass and, on the mouse click event, instantiate a QLabel with a PNG image "target" on where the click occurred.
So far I've gotten everything to work except getting the QLabel to be transparent. All of the info I've found online doesn't seem to work with the latest Qt. Should I totally rethink my design and utilize some sort of integration with painting in Qt? Or is there a way to salvage the QLabel PNG implementation and indeed make the label transparent?
Thanks,
--Dany.
QLabel inside QGraphicsView is not a good idea indeed. QGraphicsView was designed to host QGraphicsItems, to display an image you should use QGraphicsPixmapItem.
Embedding QWidget into QGraphicsView has some overhead and was really designed for complex widgets that can't be easily reimplemented in terms of QGraphicItems.
I think a QGraphicsItem with ItemIgnoresTransformations flag is just what you want.

how to drag and drop from another widget on to a QGraphicsScene

I need to drag from a QListWidget or something similar and drop on a QGraphicsScene, and create a subclass of QGraphicsItem at the drop location. Anyone have any ideas? I'm using Qt 4.6.3.
The Drag and Drop Puzzle example seems to do what you are looking for: https://doc.qt.io/archives/4.6/draganddrop-puzzle.html

Resources