You don't drag any data.
I get the impression you want to move widgets around instead.
Cheers,
_
You don't drag any data.
I get the impression you want to move widgets around instead.
Cheers,
_
Perhaps I should be using QGraphicsView?
If you want widgets that can be moved using the mouse, you can implement the movement directly in the mouse event handler methods.
The Drag&Drop classes are for transferring data, often across different applications (e.g. from a file manager to a program that should open these files).
In the most usual cases widget locations and sizes are managed by layouts, which position and resize child widgets within their parent's boundaries.
But you can manage that yourself of course.
I guess it depends on what you are trying to achieve, i.e. whether QGraphicsView is a better approach or not.
Cheers,
_
My goal is to make a desktop application in which I have multiple widgets open that the user can move around with drag/drop. Basically a to do list app (yes, I know, that is trite). Something like the following markup:
layout_example_toPost.jpg
Given that goal, do you think QGraphicsView would be better? (Note someone has responded at Stack Overflow as well and I have yet to implement their suggestions). Or more accurately, do you think it would stupid to try to do it without using QGraphicsView?
Last edited by neuronet; 6th July 2014 at 13:35. Reason: clarifying
So the only movable objects are the Todo items? Not things like the Save button or the Notes box?
I would say it is bascially a trade-off. QGraphicsView would have item moving built-in, while Widgets would have things like the tree view built-in.
If you have comfortable knowledge about widgets and no or only little know-how about graphics view I would go with widgets.
Cheers,
_
neuronet (6th July 2014)
While my simple example worked, it seems i do need to define a new MIME type for more complex examples. The following works, but I don't really understand it:
It looks more like C than Python in placesQt Code:
mimeData.setData('x-QLabel', itemData)To copy to clipboard, switch view to plain text mode![]()
I am confused.
I thought you wanted to move the Todo objects, not drag some data?
For a data drag this sounds about right, though the MIME type is usually in the form of "major/minor", e.g. "application/x-vnd.vendorname.vendorspecifictype"
Cheers,
_
neuronet (7th July 2014)
If you want to move widgets around using the mouse, then you can ignore anything related to MIME type, QMimeData or QDrag.
You just move the widget, see QWidget::move()
Cheers,
_
neuronet (7th July 2014)
Wait really?I knew I could move it around programatically using move. But it is possible to enable user to move it around with the mouse too? That sounds pretty awesome!!! Is this a good example of what youa re talking about?
http://stackoverflow.com/questions/1...-in-the-screen
If so, then wow I really do belong in the noob forum.
If anyone has a full worked out example of moving a widget around (without all this mime nonsense) that would be very helpful...The example I linked to is really a snippet, and in C++. Anything in pyside? If not c++ is fine.
Edit: it seems this is a point of confusion among many noobs, and luckily a pyqt example (which is basically pyside):
http://stackoverflow.com/questions/1...button-in-pyqt
This is actually really important. Noobs like me take the phrase 'drag and drop' in a colloquial sense to mean 'move something with the mouse', while in *qt, these two things are not the same at all. At this point I'm surprised the doc for drag 'n' drop doesn't have a huge yellow sign before starting, saying "If you want to just move something with your mouse, this is not what you want! Drag and drop is much more than that!"
I have seen so much confusion on the web about this, and generated it myself. Thanks for helping to point me int he right direction. I really wish there was a good book on this for Python users! Summerfield is good, but dated, and I am using that.
Last edited by neuronet; 7th July 2014 at 21:40.
Bookmarks