Results 1 to 7 of 7

Thread: Drag incomming localurl !=linux not work kde

  1. #1
    Join Date
    May 2006
    Posts
    788
    Thanks
    49
    Thanked 48 Times in 46 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Drag incomming localurl !=linux not work kde

    If i drag on my widged a local file in to qtextedit on mac & window the file is open
    but on linux kde no ... Why?

    result display ....
    file:///home/username/Desktop/mone.xml
    and not display file inside xml??

    kubuntu 6.0.6 uname 2.6.15


    Qt Code:
    1. void Gui_Main::dragEnterEvent(QDragEnterEvent *event)
    2. {
    3. qDebug() << "### mousePressEvent " ;
    4. event->acceptProposedAction();
    5. }
    6. void Gui_Main::dropEvent(QDropEvent *event)
    7. {
    8. if(event && event->mimeData()) {
    9. Grabdata(event->mimeData());
    10. }
    11. }
    12. void Gui_Main::Grabdata(const QMimeData *data)
    13. {
    14. if (!data) {
    15. return;
    16. }
    17. QList<QUrl> urlelist;
    18. if (data->hasUrls()) {
    19. urlelist = data->urls();
    20. for ( int i = 0; i < urlelist.size(); ++i ) {
    21. QString unfilone = urlelist.at(i).toLocalFile();
    22. qDebug() << "### url " << unfilone;
    23. if (is_file(unfilone)) {
    24. if (unfilone.endsWith(".fo")) {
    25. OpenOtherResult(unfilone);
    26. } else if (unfilone.endsWith(".xml")) {
    27. LoadXmlFile(unfilone);
    28. } else if (unfilone.endsWith(".xsl")) {
    29. LoadXsltFile(unfilone);
    30. }
    31. }
    32. }
    33. }
    34. }
    To copy to clipboard, switch view to plain text mode 
    all code on http://visual-xsltproc.svn.sourcefor...o_Debug_qt4.2/

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Drag incomming localurl !=linux not work kde

    Could you post a minimal compilable example which reproduces the problem?

  3. #3
    Join Date
    May 2006
    Posts
    788
    Thanks
    49
    Thanked 48 Times in 46 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Drag incomming localurl !=linux not work kde

    I attach file...
    here ist the small drag in url to qtextedit ...
    and a.arguments() that fail on mac on main && drag in on kde (only kde)

    you can self use the apps to read this 3 file

    main.cpp
    openmyfile.cpp
    openmyfile.h
    drag_test.pro

    qmake && make & find apps on ....

    Qt Code:
    1. TARGET = dragfile
    2. win32 {
    3. DESTDIR += ./
    4. }
    5. unix {
    6. DESTDIR += ~/Desktop
    7. }
    8. mac {
    9. DESTDIR += /Applications
    10. }
    To copy to clipboard, switch view to plain text mode 
    Attached Files Attached Files

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Drag incomming localurl !=linux not work kde

    Is it really a minimal compilable example?

    So what is the incorrect behaviour? It seems to work correctly for me (KDE 3.5.4) I drag the file onto the label, drop it and its contents appear in the text box below.

    BTW. Placing files on peoples' desktops is not something I'd call "nice". Please try to avoid it next time when posting an example.
    Last edited by wysota; 10th December 2006 at 00:52.

  5. #5
    Join Date
    May 2006
    Posts
    788
    Thanks
    49
    Thanked 48 Times in 46 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Drag incomming localurl !=linux not work kde

    Quote Originally Posted by wysota View Post
    Is it really a minimal compilable example?

    So what is the incorrect behaviour? It seems to work correctly for me (KDE 3.5.4) I drag the file onto the label, drop it and its contents appear in the text box below.

    BTW. Placing files on peoples' desktops is not something I'd call "nice". Please try to avoid it next time when posting an example.

    on my KDE not running ... kubuntu qt4.1 packace from debs url

    it display inside qtextedit "file:///path/blabla.xx"... as text not read inside

    i suppose toLocalFile(); is os different....


    Qt Code:
    1. void OpenMyFile::Grabdata(const QMimeData *data)
    2. {
    3. if (!data) {
    4. return;
    5. }
    6. QList<QUrl> urlelist;
    7. if (data->hasUrls()) {
    8. urlelist = data->urls();
    9. for ( int i = 0; i < urlelist.size(); ++i ) {
    10. QString unfilone = urlelist.at(i).toLocalFile();
    11. /////qDebug() << "### url " << unfilone;
    12. QFile f(unfilone);
    13. if (f.exists()) {
    14. OpenFile(unfilone);
    15. }
    16.  
    17. }
    18. }
    19. }
    To copy to clipboard, switch view to plain text mode 

  6. #6
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Drag incomming localurl !=linux not work kde

    Quote Originally Posted by patrik08 View Post
    it display inside qtextedit "file:///path/blabla.xx"... as text not read inside
    You're dropping on a wrong widget. The text edit has its own drop handler which is displaying text carried by the drag and it happens that URLs are stored as text, so it's a perfectly good drag for the text edit, so it handles the event and doesn't pass it to a parent widget where your drop handler resides. Try dropping outside the text edit.

    i suppose toLocalFile(); is os different....
    Of course it's os specific, but toLocalFile() doesn't have anything to do here - it's not even called when you drop on the text edit.

  7. #7
    Join Date
    Jan 2006
    Location
    Kerala
    Posts
    371
    Thanks
    76
    Thanked 37 Times in 32 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Drag incomming localurl !=linux not work kde

    You're dropping on a wrong widget. The text edit has its own drop handler which is displaying text carried by the drag and it happens that URLs are stored as text, so it's a perfectly good drag for the text edit, so it handles the event and doesn't pass it to a parent widget where your drop handler resides. Try dropping outside the text edit.
    Or from the C++ Gui programming Book

    Suppose the QTextEdit is inside a main Window then
    Qt Code:
    1. MainWindow::MainWindow( ... ){
    2. [...]
    3. textEdit->setAcceptDrops( false );
    4. setAcceptDrops( true );
    5. }
    6.  
    7. void MainWindow::dragEnterEvent( QDragEnterEvent *e ) {
    8. // accept if you can decode the mime data
    9. }
    10.  
    11. void MainWindow::dropEvent( QDropEvent *e ) {
    12. // get the file from the mime Data
    13. readFile( file );
    14. }
    To copy to clipboard, switch view to plain text mode 
    We can't solve problems by using the same kind of thinking we used when we created them

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.