Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. DnDcontainer in QStateMachine, Drag and Drop no longer works?
Qt 6.11 is out! See what's new in the release blog

DnDcontainer in QStateMachine, Drag and Drop no longer works?

Scheduled Pinned Locked Moved General and Desktop
2 Posts 2 Posters 1.5k Views 1 Watching
  • 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 Offline
    Q Offline
    qtuser1
    wrote on last edited by
    #1

    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
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      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
      0

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved