Important: Please read the Qt Code of Conduct -

DnDcontainer in QStateMachine, Drag and Drop no longer works?

  • I have a DnDcontainer in Screen3 below. Drag and Drop into the DnDcontainer used to work fine, until I updated the project to use QStateMachine and QAbstractTransition, to add simple transitions between screens. After adding the transitions, everything works except Drag and Drop to the DnDcontainer, the DnDcontainer::dragEnterEvent and DnDcontainer::dropEvent methods are never executed, and when hovering over the DnDcontainer, I get a circle with a slash through it. What am I missing here? How do I pass the Drag and Drop signal to the DnDcontainer?

    @Screen1 *_screen1 = new Screen1;
    Screen2 *_screen2 = new Screen2;
    Screen3 *_screen3 = new Screen3;
    QGraphicsProxyWidget *_screen2Proxy = new QGraphicsProxyWidget;
    QGraphicsProxyWidget *_screen1Proxy = new QGraphicsProxyWidget;
    QGraphicsProxyWidget *_screen3Proxy = new QGraphicsProxyWidget;

    Pixmap *_stepper = new Pixmap(QPixmap(":/Images/imgs/stepper.png"));
    Pixmap *_player = new Pixmap(QPixmap(":/Images/imgs/player.png"));
    Pixmap *_stext = new Pixmap(QPixmap(":/Images/imgs/stepper-text.png"));

    QWidget *_tb = new QWidget;
    _tb->setStyleSheet("background-image: url(:/Images/imgs/menubar-full.png);background-repeat: repeat-x;");
    QGraphicsProxyWidget *_tbProxy = new QGraphicsProxyWidget;


    QStateMachine machine;
    QState *state1 = new QState(&machine);
    QState *state2 = new QState(&machine);
    QState *state3 = new QState(&machine);

    // state1
    state1->assignProperty(_tbProxy, "geometry", QRect(0, 0, w, 42));
    state1->assignProperty(_screen3Proxy, "geometry", QRect(0, 0, w, h));
    state1->assignProperty(_screen1Proxy, "geometry", QRect(w, 50, w, h));
    state1->assignProperty(_screen2Proxy, "geometry", QRect(2*w, 50, w, h));
    state1->assignProperty(_stepper, "pos", QPointF(w-154, 0));
    state1->assignProperty(_player, "pos", QPointF(w-154, 0));
    state1->assignProperty(_stext, "pos", QPointF(w-154, 0));
    // view
    state1->assignProperty(_tbProxy, "opacity", qreal(1));
    state1->assignProperty(_screen3Proxy, "opacity", qreal(1));
    state1->assignProperty(_screen1Proxy, "opacity", qreal(0));
    state1->assignProperty(_screen2Proxy, "opacity", qreal(0));
    state1->assignProperty(_stepper, "opacity", qreal(1));
    state1->assignProperty(_player, "opacity", qreal(1));
    state1->assignProperty(_stext, "opacity", qreal(1));@

  • Lifetime Qt Champion

    Hi and welcome to DevNet,

    Are you sure that the DnDContainer has the right size ?

    What properties do the other states set ?

Log in to reply