Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Call for Presentations - Qt World Summit

    DnDcontainer in QStateMachine, Drag and Drop no longer works?

    General and Desktop
    2
    2
    1023
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • Q
      qtuser1 last edited by

      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;
      _screen2Proxy->setWidget(_screen2);
      QGraphicsProxyWidget *_screen1Proxy = new QGraphicsProxyWidget;
      _screen1Proxy->setWidget(_screen1);
      QGraphicsProxyWidget *_screen3Proxy = new QGraphicsProxyWidget;
      _screen3Proxy->setWidget(_screen3);

      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;");
      _tb->setMinimumHeight(42);
      _tb->setMinimumWidth(w);
      QGraphicsProxyWidget *_tbProxy = new QGraphicsProxyWidget;
      _tbProxy->setWidget(_tb);

      scene->addItem(_tbProxy);
      scene->addItem(_screen3Proxy);
      scene->addItem(_screen1Proxy);
      scene->addItem(_screen2Proxy);
      scene->addItem(_stepper);
      scene->addItem(_player);
      scene->addItem(_stext);

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

      // 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));@

      1 Reply Last reply Reply Quote 0
      • SGaist
        SGaist Lifetime Qt Champion last edited by

        Hi and welcome to DevNet,

        Are you sure that the DnDContainer has the right size ?

        What properties do the other states set ?

        Interested in AI ? www.idiap.ch
        Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

        1 Reply Last reply Reply Quote 0
        • First post
          Last post