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. Drag & Drop and Context Menu problem QGraphicsScene
Forum Updated to NodeBB v4.3 + New Features

Drag & Drop and Context Menu problem QGraphicsScene

Scheduled Pinned Locked Moved General and Desktop
11 Posts 3 Posters 7.4k 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.
  • F Offline
    F Offline
    Franzk
    wrote on last edited by
    #2

    You put down a lot of text but you fail to be specific:

    [quote]I write proper code but it does not work.[/quote]

    what exactly doesn't work? You expect something and you see something. What do you expect and what do you see (or not)?

    "Horse sense is the thing a horse has which keeps it from betting on people." -- W.C. Fields

    http://www.catb.org/~esr/faqs/smart-questions.html

    1 Reply Last reply
    0
    • O Offline
      O Offline
      onurozcelik
      wrote on last edited by
      #3

      Sorry for my bad explanation.

      Draging & Droping to QGraphicsScene works.

      Context menu event on item inside scene does not work.

      1 Reply Last reply
      0
      • F Offline
        F Offline
        Franzk
        wrote on last edited by
        #4

        What happens if you do

        @void SwitchItem::contextMenuEvent(QGraphicsSceneContextMenuEvent *e)
        {
        contextMenu->move(e->screenPos());
        contextMenu->show();
        }@

        instead? Maybe there's an issue with calling an event loop within an event loop here. (Can't be too sure).

        "Horse sense is the thing a horse has which keeps it from betting on people." -- W.C. Fields

        http://www.catb.org/~esr/faqs/smart-questions.html

        1 Reply Last reply
        0
        • O Offline
          O Offline
          onurozcelik
          wrote on last edited by
          #5

          Nothing happens. Code does not even enter contextMenuEvent

          1 Reply Last reply
          0
          • F Offline
            F Offline
            Franzk
            wrote on last edited by
            #6

            Did you set the "QWidget::contextMenuPolicy":http://doc.trolltech.com/latest/qwidget.html#contextMenuPolicy-prop correctly?

            "Horse sense is the thing a horse has which keeps it from betting on people." -- W.C. Fields

            http://www.catb.org/~esr/faqs/smart-questions.html

            1 Reply Last reply
            0
            • O Offline
              O Offline
              onurozcelik
              wrote on last edited by
              #7

              Why should I set that?

              1 Reply Last reply
              0
              • F Offline
                F Offline
                Franzk
                wrote on last edited by
                #8

                Well, if it's not Qt::DefaultContextMenu, you don't get the event.

                "Horse sense is the thing a horse has which keeps it from betting on people." -- W.C. Fields

                http://www.catb.org/~esr/faqs/smart-questions.html

                1 Reply Last reply
                0
                • O Offline
                  O Offline
                  onurozcelik
                  wrote on last edited by
                  #9

                  It is not related with that. Its default option is Qt::DefaultContextMenu

                  1 Reply Last reply
                  0
                  • N Offline
                    N Offline
                    NarutoUzumakis
                    wrote on last edited by
                    #10

                    could you please send me the whole project,every class and header file,including the main method.I have to do something similar ,just the drag and drop action,but i'm having difficulties with it and your complete code would be a great help for me..
                    I am supposed to do some college project,but i am seriously stuck,i've tried everything,searching online,doing it myself,but there's always some tiny error which messes everything up.Your code would definitely help me a lot..
                    my email is
                    narutouzumakis@live.com

                    Thank you in advance

                    Nikolas

                    1 Reply Last reply
                    0
                    • N Offline
                      N Offline
                      NarutoUzumakis
                      wrote on last edited by
                      #11

                      or can anyone at least show me how the main function would look like,how everything should be called and initialized,please..
                      thanks

                      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