Results 1 to 10 of 10

Thread: <SOLVED > Treeview select draged Item or set mime data from draged item

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Aug 2015
    Posts
    25
    Thanks
    3
    Qt products
    Qt5
    Platforms
    Unix/X11

    Default Re: <SOLVED > Treeview select draged Item or set mime data from draged item

    Quote Originally Posted by anda_skoa View Post
    Is this a good idea?
    As a side note: that setUrls() call doesn't make much sense, you are not filling the list anywhere, right?
    I append the filename to it. Or is there a way to set just one Url directly?
    Qt Code:
    1. urllist.append(QString("file:"+filename));
    To copy to clipboard, switch view to plain text mode 

    How do you reimplement startDrag() ?

    I tried it this way?

    Qt Code:
    1. void customtreeview::startDrag()
    2. {
    3.  
    4. }
    To copy to clipboard, switch view to plain text mode 
    and put a qDebug in it, but it's never called.
    Otherwise what you say make perfect sense, but out of ignorance I am still stuck with my workaround.

    And model()->Data() just returns the filename without path. So it isn't much use to me either.

  2. #2
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: <SOLVED > Treeview select draged Item or set mime data from draged item

    Quote Originally Posted by 0backbone0 View Post
    I append the filename to it. Or is there a way to set just one Url directly?
    Qt Code:
    1. urllist.append(QString("file:"+filename));
    To copy to clipboard, switch view to plain text mode 
    Right, sorry, missed that line.
    Better use QUrl::fromLocalFile() instead of string concatentation though.

    Quote Originally Posted by 0backbone0 View Post
    How do you reimplement startDrag() ?

    I tried it this way?

    Qt Code:
    1. void customtreeview::startDrag()
    To copy to clipboard, switch view to plain text mode 
    and put a qDebug in it, but it's never called.
    This is not the correct signature, you are missing the argument.


    Quote Originally Posted by 0backbone0 View Post
    And model()->Data() just returns the filename without path. So it isn't much use to me either.
    Ah, but you can also retrieve the path, QFileSystemModel::FilePathRole.
    Anyway, casting should be fine, but you might want to check the result of the cast for null pointer.

    Cheers,
    _

  3. #3
    Join Date
    Aug 2015
    Posts
    25
    Thanks
    3
    Qt products
    Qt5
    Platforms
    Unix/X11

    Default Re: <SOLVED > Treeview select draged Item or set mime data from draged item

    The documentation sais:
    Qt Code:
    1. void QAbstractItemView::startDrag(Qt::DropActions supportedActions) [virtual protected]
    2. Starts a drag by calling drag->exec() using the given supportedActions.
    To copy to clipboard, switch view to plain text mode 
    If I use Qt:ropActions as an Argument I get the Error:

    variable or field 'startDrag' declared void
    void customtreeview::startDrag(Qt::IgnoreAction)

    What now? Any link to an example perhaps?

  4. #4
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: <SOLVED > Treeview select draged Item or set mime data from draged item

    Quote Originally Posted by 0backbone0 View Post
    The documentation sais:
    Qt Code:
    1. void QAbstractItemView::startDrag(Qt::DropActions supportedActions) [virtual protected]
    2. Starts a drag by calling drag->exec() using the given supportedActions.
    To copy to clipboard, switch view to plain text mode 
    Exactly!

    Quote Originally Posted by 0backbone0 View Post
    If I use Qt:ropActions as an Argument I get the Error:

    variable or field 'startDrag' declared void
    void customtreeview::startDrag(Qt::IgnoreAction)
    That looks wrong, almost like you had written exactly that instead of the actual method signature.

    Cheers,
    _

Similar Threads

  1. Finding a item in second column of treeView
    By cszawisza in forum Newbie
    Replies: 5
    Last Post: 20th September 2013, 00:19
  2. Auto Layout TreeView's item?
    By jerry7 in forum Qt Programming
    Replies: 3
    Last Post: 21st September 2010, 06:48
  3. Replies: 1
    Last Post: 28th July 2009, 06:58
  4. current item in treeview
    By kernel_panic in forum Qt Programming
    Replies: 2
    Last Post: 30th October 2007, 19:26
  5. TreeView click item not connecting
    By Big Duck in forum Qt Programming
    Replies: 2
    Last Post: 9th June 2006, 19:38

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
  •  
Qt is a trademark of The Qt Company.