Solved Drag and drop text displayed between QGLWidget
-
These are empty methods, you won't get custom drag and drop behaviour with just that.
Did you read the dedicated chapter about it in Qt's documentation ?
-
@SGaist Thank you.
Will go through that and try.. -
Hi
The
http://doc.qt.io/qt-5/qtwidgets-draganddrop-draggabletext-example.html
is pretty close to what you want. -
@mrjj Thank you.
Will try it and update. -
I was trying to use Q_DECLARE_METATYPE in drag object to copy the data from one widget to another.
The meta type is declared something like below:
Class MyView : public QGLWidget, public BaseWidget
{
public:
struct my_struct{
int m_var;
};
Q_DECLARE_METATYPE(my_struct)
};
But I am getting following errors:
error: explicit specialization in non-namespace scope ‘class MyView’
error: expected primary-expression before ‘>’ token reinterpret_cast< TYPE *>(quintptr(-1)));
error: expected ‘(’ before ‘my_struct’ Q_DECLARE_METATYPE(my_struct)What is right way of declaring a Q_DECLARE_METATYPE ?
-
Hi
I think it likes better if classes are not nested.
struct my_struct{
int m_var;
};
Q_DECLARE_METATYPE(my_struct)Class MyView : public QGLWidget, public BaseWidget
{
public:
my_struct myvar;
}; -
@mrjj : Thank you! you are absolutely right :)
One more query is how to handle mouse events when drag object is used ?
drag object seems to block all the mouse events.I have created a drag object inside mousePressEvent() . Wanted to copy the string list from one widget to another.
I wanted to handle dropping of QList in mouseReleaseEvent() but as soon as drag object is created it blocks all mouse events. -
@QtVik
Super.Regarding drag & drop.
You should fully use the drag system to do so.
http://doc.qt.io/qt-5/dnd.html
http://doc.qt.io/qt-5/qdropevent.htmlHere it drops pictures.
http://doc.qt.io/qt-5/qtwidgets-draganddrop-puzzle-example.html
you can drop anything u like this way. -
@mrjj Thank you ! will try that and update..
-