First step was:In the second step I enabled drops for textEditCode:
MainWindow::MainWindow() { setCentralWidget(textEdit); textEdit->setAcceptDrops(false); setAcceptDrops(true); setWindowTitle(tr("Text Editor")); } { event->accept(); } { event->accept(); } { if (event->mimeData()->hasFormat("text/uri-list")) { QList<QUrl> urls = event->mimeData()->urls(); if (urls.isEmpty()) return; if (fileName.isEmpty()) return; if (readFile(fileName)) setWindowTitle(tr("%1 - %2").arg(fileName) .arg(tr("Drag File"))); } }
and subclassed it, so now it's possible to move/copy a text from a line to another:Code:
textEdit->setAcceptDrops(true)
My questions:Code:
{ if (e->source()) { if (e->source()->objectName() == "qt_scrollarea_viewport") { e->accept(); } } } { e->accept(); }
1. During drag the cursor stays hidden: is this due to the non-propagation of the event to the parent?
2. Why subclassing dropEvent() like thistext is not copied/moved?
3. Are there any alternatives to get this task?
I hope this thread will be useful for others.
Thank you so much.