Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. International
  3. Polish
  4. Funkcja dropEvent(QGraphicsSceneDragDropEvent *event) nie przechwytuje zdarzeń
Qt 6.11 is out! See what's new in the release blog

Funkcja dropEvent(QGraphicsSceneDragDropEvent *event) nie przechwytuje zdarzeń

Scheduled Pinned Locked Moved Polish
1 Posts 1 Posters 1.1k 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.
  • M Offline
    M Offline
    maniek_1990
    wrote on last edited by
    #1

    Witam. Piszę grę w statki i przy przenoszeniu statków chcę je upuścić aby następnie wyczytać ich pozycję i robić inne rzeczy. Problem w tym że funkcja od przechwytu DropEvent nie działa.
    Samo przenoszenie statku mam zaimplementowane przez dodanie flagi ;

    statek_1->setFlag(QGraphicsItem::ItemIsMovable);

    Poniżej wycinek kodu deklaracji statka typu QGraphicsItem w konstruktorze:

    QPixmap dwuMasztowiec;
    dwuMasztowiec = QPixmap("../Statki/images/dwu.png");
    statek_1 = scene->addPixmap(dwuMasztowiec);
    statek_1->setPos(277,405);
    statek_1->setFlag(QGraphicsItem::ItemIsMovable);

    a następnie kod funkcji dropEvent (skopiowany z przykładu o robocie)

    void Plansza::dropEvent(QGraphicsSceneDragDropEvent *event)
    {
    if (event->mimeData()->hasImage()) {
    dragOver = false;
    pixmap = qVariantValue<QPixmap>(event->mimeData()->imageData());
    update();
    } else {
    Plansza::dropEvent(event);
    }
    }

    I chcę jeszcze dopowiedzieć że w konstruktorze dodałem funkcje : setAcceptDrops(true)

    Proszę o pomoc. W razie potrzeby wrzucę cały kod. Pzd

    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