Forum
Sign Up
× DataGrid for Qt.C++

Drag and Drop.

1 year 6 months ago #1 by GYEYOUNG TNI CO LTD
The drag & drop function is not working properly.

1. first, I set the grid as below: ( Qt 5.15.9 )

spView->options().setDragEnabled( true );
spView->options().setDropEnabled( true );
spView->options().setDragDropMode( QAbstractItemView::DragDrop );
spView->options().setSupportedDropActions( Qt::CopyAction | Qt::MoveAction );
spView->options().setModelItemsDragEnabled( true );

connect( spView, &Qtitan::GridViewBase::startDragDrop, this, &QDlgExplorer::oo_grdLocal_startDragDrop );
connect( spView, &Qtitan::GridViewBase::endDragDrop, this, &QDlgExplorer::oo_grdLocal_endDragDrop );
connect( spView, &Qtitan::GridViewBase::checkDragDrop, this, &QDlgExplorer::oo_grdLocal_checkDragDrop );
connect( spView, &Qtitan::GridViewBase::dragDrop, this, &QDlgExplorer::oo_grdLocal_dragDrop );


2. startDragDrop and endDragDrop are called, but checkDragDrop and dragDrop are not.

Also, in startDragDrop


void QDlgExplorer::oo_grdLocal_startDragDrop( DragArgs* Args )
{ if
FUNC_OBJ_TO( logger, Args->row() );
viewClickTimer.stop();
auto data = new QMimeData;
data->setImageData( driveIcon );

Args->setMimeData( data );
Args->setSupportedDropActions( Qt::CopyAction | Qt::MoveAction );
Args->setDefaultDropAction( Qt::DropAction::CopyAction );

Args->setAccepted( true );
//Args->setHandled( true );
}

No matter what combination of setAccepted and sethandled you use above, the mouse cursor's icon will be banned when you start dragging.

3. endDragDrop is called, but the Args passed in always contain no value.

4. After debugging the internal code, I realized that QDrag::Exec always returns Qt::IgnoreAction. What is the reason for this?

5. If I change the value set in spView->options().setSupportedDropActions( Qt::CopyAction | Qt::MoveAction );; in 1) to Qt::InternalMove, the same happens.


What you want: Notification of Drag & Drop inside the Grid, notification when items inside the Grid are dragged and dropped outside the Grid (to another widget or another process (Desktop, Windows Explorer, etc.. ) ), notification when items are dragged and dropped into the Grid from inside or outside the Grid.

Please Log in or Create an account to join the conversation.

More
1 year 5 months ago #2 by GYEYOUNG TNI CO LTD
Replied by GYEYOUNG TNI CO LTD on topic Drag and Drop.
hm... hello?? anybody??

Please Log in or Create an account to join the conversation.

More
1 year 5 months ago #3 by Developer Machines
Replied by Developer Machines on topic Drag and Drop.
Could you please specify what version of grid are you using? Do you have the opportunity to send us a complete example to reproduce the problem?

Note that checkDragDrop is called when the drag data comes from outside. This event usually occurs by QWidget::dragMoveEvent(QDragMoveEvent* event). In general, the handling the drag-drop is similar to that is using in the regular Qt table.

Args->setAccepted( true ); - This code line is needed to pass the accept flag to the Qt events that was the reason.
Args->setHandled( true ); This flag should be set if you take control for the drag-drop operation. If it is true - next, you must fill the mime-data, call QDrag::exec() and so on. Usually, this is not necessary and the grid does it automatically.

Please Log in or Create an account to join the conversation.

More
1 year 5 months ago #4 by GYEYOUNG TNI CO LTD
Replied by GYEYOUNG TNI CO LTD on topic Drag and Drop.
i use 8.0 beta1,

ps. When is the official release date for 8.0?

Please Log in or Create an account to join the conversation.

More
1 year 5 months ago #5 by Developer Machines
Replied by Developer Machines on topic Drag and Drop.
The public beta version will be released in the second half of August and the final release will be in September.

Please Log in or Create an account to join the conversation.

More
  • Not Allowed: to create new topic.
  • Not Allowed: to reply.
  • Not Allowed: to edit your message.
Moderators: Developer Machines
Time to create page: 0.204 seconds

Developer Newsletter

Join our Developer Machines newsletter to get informed on all the latest releases of the commercial components for Qt.C++, Delphi FireMonkey, updates and general knowledges.

Quick Support

Should you need any additional information about our products or licensing, please contact us at the following email addresses:

  • This email address is being protected from spambots. You need JavaScript enabled to view it.

  • This email address is being protected from spambots. You need JavaScript enabled to view it.

Get in Touch

If you would like to purchase our products or services, but don’t know how to do it the right way, please feel free to contact us:

  • This email address is being protected from spambots. You need JavaScript enabled to view it.( any questions related to our products or services )
  • This email address is being protected from spambots. You need JavaScript enabled to view it.( questions related to licensing )