Results 1 to 4 of 4

Thread: QX11EmbedContainer Drag and Drop

  1. #1

    Default QX11EmbedContainer Drag and Drop

    Drag and drop events aren´t working for QX11EmbedContainer. Any ideas? The acceptDrop property is enabled.

  2. #2

    Default Re: QX11EmbedContainer Drag and Drop

    The application of the QX11EmbedContainer is the following:


    #include <QtGui>
    #include <QX11EmbedContainer>

    //! [0]
    int main(int argc, char *argv[])
    {
    QApplication app(argc, argv);

    if (app.arguments().count() != 2) {
    qFatal("Error - expected executable path as argument");
    return 1;
    }

    QX11EmbedContainer container;
    container.show();
    container.setAcceptDrops(true);
    QProcess process(&container);
    QString executable(app.arguments()[1]);
    QStringList arguments;
    arguments << QString::number(container.winId());
    process.start(executable, arguments);

    int status = app.exec();
    process.close();
    return status;
    }

    The QX11EmbedWidget application is divided into a main function and EmbedWidget class. The EmbedWidget class inherits QX11EmbedWidget and implements the drag and drop events.

    ------------------------------main.cpp------------------------------------------

    #include <QApplication>
    #include <QWidget>
    #include <QDebug>
    #include "embedwidget.h"

    //! [0]
    int main(int argc, char *argv[])
    {
    QApplication app(argc, argv);
    EmbedWidget window;
    if (app.arguments().count() != 2)
    {
    window.show();
    }
    else
    {
    QString windowId(app.arguments()[1]);
    window.embedInto(windowId.toULong());
    window.show();
    }

    return app.exec();
    }

    -------------------------------embedwidget.h-------------------------------------------
    #ifndef EMBEDWIDGET_H
    #define EMBEDWIDGET_H

    #include <QRadialGradient>
    #include <QSize>
    #include <QX11EmbedWidget>

    class QPaintEvent;

    class EmbedWidget : public QX11EmbedWidget
    {
    Q_OBJECT

    public:
    EmbedWidget(QWidget *parent = 0);
    QSize sizeHint() const;
    void dragEnterEvent(QDragEnterEvent *event);
    void dragMoveEvent(QDragMoveEvent *event);
    void dragLeaveEvent(QDragLeaveEvent *event);
    void dropEvent(QDropEvent *event);

    protected:
    void paintEvent(QPaintEvent *event);

    private:
    QRadialGradient gradient;
    };

    #endif

    ---------------------------------EmbedWidget.cpp---------------------------------------

    #include <QtGui>
    #include <QDragEnterEvent>

    #include "embedwidget.h"

    EmbedWidget::EmbedWidget(QWidget *parent)
    : QX11EmbedWidget(parent)
    {
    gradient = QRadialGradient(100, 100, 90, 60, 60);
    gradient.setColorAt(0.0, Qt::white);
    gradient.setColorAt(0.9, QColor(192, 192, 255));
    gradient.setColorAt(1.0, QColor(0, 32, 64));
    setAcceptDrops(true);
    }



    QSize EmbedWidget::sizeHint() const
    {
    return QSize(600, 600);
    }

    void EmbedWidget::dragEnterEvent(QDragEnterEvent *event)
    {

    event->accept();
    }

    void EmbedWidget::dragMoveEvent(QDragMoveEvent *event)
    {
    event->accept();
    }

    void EmbedWidget::dragLeaveEvent(QDragLeaveEvent *event)
    {
    event->accept();
    }


    Added after 6 minutes:


    The embedwidget accepts all the drag and drop events correctly when executed separately from the container. This does not work properly when the process is executed inside the container.
    Last edited by Tweety66; 14th May 2013 at 11:42.

  3. #3
    Join Date
    Nov 2007
    Posts
    1
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: QX11EmbedContainer Drag and Drop

    Hello,

    Any luck with this? We are experiencing the same issue. Additionally, we notice that wreckless dragging outside of the container's window will cause one or both programs to crash.

    Thanks,
    Kurt

  4. #4
    Join Date
    Aug 2010
    Posts
    12
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default Re: QX11EmbedContainer Drag and Drop

    Hello,

    i'am facing the same problem. There are no DnD-related events being propagated. Furthermore i cannot handle contextmenu-events.

    Has anybody an idea? Is there a BUG in Qt?

    greetz

Similar Threads

  1. Replies: 0
    Last Post: 7th January 2012, 15:20
  2. Replies: 2
    Last Post: 13th October 2010, 21:51
  3. Replies: 3
    Last Post: 10th June 2010, 15:13
  4. Replies: 0
    Last Post: 4th May 2010, 10:24
  5. Drag and Drop (drop example)
    By din9 in forum Qt Programming
    Replies: 1
    Last Post: 23rd January 2006, 18:03

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.