Skip to content
QtWS25 Last Chance
  • Bug in Qt 5.12 drag n'drop ?

    Unsolved General and Desktop qat 5.12 drag n drop
    57
    0 Votes
    57 Posts
    15k Views
    Christian EhrlicherC
    The bug will be fixed in 5.12.1
  • Drag and Drop into empty widget space

    Solved General and Desktop drag and drop qwidget drop drag
    5
    0 Votes
    5 Posts
    3k Views
    mrjjM
    @Vagabond Heh. good work. Just as a note: you can use event filters to implement drag and drop on other widgets if no other need to subclass them. http://ynonperek.com/course/qt/event-filter2.html But for your case, subclassing QGroupBox is super.
  • Drag and drop image from application to windows explorer

    Unsolved General and Desktop drag drop
    4
    0 Votes
    4 Posts
    3k Views
    raven-worxR
    @AliReza-Beytari So to enable drops to the filesystem you should add a file urls (using QMimeData::setUrls() for example). For photoshop it might be enough to set a image on the mimedata (using QMimeData::setPixmap()) Take a look at the Delayed encoding example. The interesting part here is the QMimeData::retrieveData() overload. This method gets called when a drop happens. So when a drop to the filesystem happens the mimedata requests the data and calls retrieveData(). In there you write your pixmap data to a temporary image file. For that you can use QTemporaryFile class for example. Write the data to the temporary file and return the url to the file. Mime-Type: "text/uri-list" Analog for the pixmap image. Simply return the QPixmap. Mime-Type: "image/png" Actually it could also be necessary to return the PNG binary data. I am not sure. This can be done like this: QPixmap pixmap; QByteArray data; QBuffer buffer(&data); buffer.open(QIODevice::WriteOnly); pixmap.save(&buffer, "PNG"); buffer.close(); The advantage of this approach is that you only create the drop data when necessary. Especially the temp file used for drops to the filesystem.
  • QTreeView drop not working

    Solved General and Desktop qtreeview drop drag and drop
    2
    0 Votes
    2 Posts
    4k Views
    Joel BodenmannJ
    This issue is now resolved. It turned out to be a problem in the model: I forgot to tell the root (invalid parent) to accept drops too. This is done in the QAbstractItemModel::flags() implementation. The incorrect version was: Qt::ItemFlags MyModel::flags(const QModelIndex& index) const { if (!index.isValid()) { return 0; } return Qt::ItemIsEnabled | Qt::ItemIsSelectable | Qt::ItemIsDropEnabled; } While this is how it should look like to allow drops in the root (to add new items without a parent): Qt::ItemFlags MyModel::flags(const QModelIndex& index) const { if (!index.isValid()) { return Qt::ItemIsDropEnabled; // Allow drops in the top-level (no parent) } return Qt::ItemIsEnabled | Qt::ItemIsSelectable | Qt::ItemIsDropEnabled; }
  • 0 Votes
    10 Posts
    8k Views
    V
    Well, I found solution. It is very simple, all I need is to set default drop action for my view class as Qt::MoveAction and return copy and move in the suporrtedDropActions().
  • 0 Votes
    8 Posts
    4k Views
    J
    @Jakob Hm, it seems I didn't refresh - you already did mark as solved - my apologies