You are not logged in.

Dear visitor, welcome to QtForum.org. If this is your first visit here, please read the Help. It explains in detail how this page works. To use all features of this page, you should consider registering. Please use the registration form, to register here or read more information about the registration process. If you are already registered, please login here.

1

Monday, June 29th 2015, 7:46pm

Qt 4.8.6 DND Windows 7 empty URL list

Hello all,

I am trying to enable drag and drop of files from Windows explorer to my application.

On my main window widget which subclasses QDialog I have called setAcceptDrops(true); in the constructor.

I have overridden dropEvent(...) and dragEnterEvent(...) and confirmed that they are being called, but when I drag a file from Windows explorer onto my application, my Url list is empty.

Windows 7 Pro SP1, Qt 4.8.6 downloaded from http://tver-soft.org/qt64 (32 bit)

Has anyone else experienced this?

Adam

Source code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
//-----------------------------------------------------------------------------
PlusServerLauncherMainWindow::PlusServerLauncherMainWindow(QWidget *parent, Qt::WFlags flags, bool autoConnect) 
 : QDialog(parent, flags|Qt::WindowMinimizeButtonHint) 
 , m_DeviceSetSelectorWidget(NULL)  , m_CurrentServerInstance(NULL)
{ 
  setAcceptDrops(true);
  ...

//-----------------------------------------------------------------------------
void PlusServerLauncherMainWindow::dropEvent(QDropEvent* ev)
{
 foreach (const QUrl &url, ev->mimeData()->urls())
 {
   const QString &fileName = url.toLocalFile();    qDebug() << "Dropped file:" << fileName;
 }
}
//-----------------------------------------------------------------------------
void PlusServerLauncherMainWindow::dragEnterEvent(QDragEnterEvent* ev)
{ 
 if (ev->mimeData()->hasUrls()) 
{    ev->acceptProposedAction();  }
}