c++ - Getting "QFile::rename: Empty or null file name" when dropping file to QTreeView -
i have qsplitter of :
left side qtreeview showing local system file using qfilesystemmodel
right side have qwebview html page showing directory , file name line line returned api.
i want make drag , drop application. have enable drag , drop required functions working internally on own view.
but want drag , drop between these 2 views, , when doing this, it's showing plus icon correctly, when dropping file, showing in console :
qfile::rename: empty or null file name
here's code :
qstringlistmodel *model1 = new qstringlistmodel(); qstringlist *stringlist = new qstringlist(); view2->setupdatesenabled(true); view2->setacceptdrops(true); if(oldname == "" || cpe == "") { oldname = cpe; } else { oldname = oldname + " / " + cpe; } view2->page()->mainframe()->addtojavascriptwindowobject("mainwindow",newmyjavascriptoperations); qstring mypage; qtextstream p(&mypage); p << "<!doctype html>"; p <<"<html><head>\n<link rel='stylesheet' type='text/css'"; {width:350px;height:70px;padding:10px;border:1px solid #aaaaaa;} </style>"; p << " href='webview.css' />\n"; p <<"<link href='file:///d:/qt/qt_js/bootstrap.min.css' rel='stylesheet'>"; p << "<style type='text/css'>body { color:black }; </style>"; p<<"<script src='file:///d:/qt/qt_js/selectcpe.js'></script>"; p << "<body ondragstart='return true'>"; p << "<ol class='breadcrumb'>"; if(cpe == null){ qdebug()<<"cpe1"; p << "<li class='active'>"<<cpename<<"</li>"; } else{ qdebug()<<"cpe2"; p << "<li><a href='javascript:void(0)' onclick = 'cpecontent()'>"<<cpename<<"</a></li>"; p << "<li class='active'>"<<oldname<<"</li>"; } p<<"</ol>"; </div>"; p<<"<div class='row'>"; while(tmp!= null) { if (tmp->isdir) { p<<"<div class='col-lg-3'>"; p<< "<a draggable='true' width='336' height='69' href='javascript:void(0)' onclick = 'opendir(this.id)' id="<< tmp->filename<<">"; p << "<img src='file:///d:/qt/qt_js/manilla_gnome_fs_directory.png' class='logo'><br>"; p <<"dirname: "<< tmp->filename <<"</a></div>"; } else { p<<"<div class='col-lg-3'>"; p<< "<a href='javascript:void(0)' draggable='true'>"; p << "<img src='file:///d:/qt/qt_js/document_folder_blue.png' class='logo'><br>"; float size = tmp->size/(1024*1024); p <<"filename: "<< tmp->filename <<"<br>"<<"size: "<<size<<" mb</a></div>"; } p<<"<br><br><br>"; tmp = (filenode_t *)tmp->next; } p<<"</div>"; if(head) { qdebug()<<"display"; } else { p <<"no contents..."; } model1->setstringlist(*stringlist); freefilelist(head); head = null; view2->sethtml(mypage); view2->setacceptdrops(true); qdebug() << "in main2 method"; view1->hide(); //tree qdebug() << "in main3 method"; qfilesystemmodel *model = new qfilesystemmodel; model->setreadonly(false); qstring dir("c:/sample"); model->setrootpath(dir); tree->update(); tree->repaint(); tree->resize(1100, 550); tree->setmodel(model); tree->setrootindex(model->index((dir))); tree->setselectionmode(qabstractitemview::extendedselection); tree->setdragenabled(true); tree->settextelidemode(qt::elidemiddle); tree->viewport()->setacceptdrops(true); tree->setacceptdrops(true); tree->setdropindicatorshown(true); tree->setdefaultdropaction(qt::copyaction); tree->setdragdropmode(qabstractitemview::dragdrop); splitter->setacceptdrops(true); splitter->addwidget(tree); splitter->addwidget(view2); splitter->resize(1100, 550); splitter->setwindowtitle("<- local files , api files ->"); splitter->show();
Comments
Post a Comment