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. CustomContextMenuRequested not sending signal with QTreeWidget
Forum Updated to NodeBB v4.3 + New Features

CustomContextMenuRequested not sending signal with QTreeWidget

Scheduled Pinned Locked Moved Unsolved General and Desktop
5 Posts 3 Posters 3.2k 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.
  • C Offline
    C Offline
    Cysis145
    wrote on last edited by
    #1

    Hi guys,

    I'm try to create a system where in a QTreeWidget, each item has its own right click menu. I know how to go about making the custom menus for each item however what i am struggling with is catching the signal which will run my function to create/update the right-click menus accordingly

    Here is my code:

    Header file
    ============
    private slots:
    void WorldItemMenu(const QPoint &point);
    
    
    CPP file
    =============
    (in the constructor)
    //World Panel
        ui->TW_World->setContextMenuPolicy(Qt::ActionsContextMenu);
        connect(ui->TW_World, SIGNAL(customContextMenuRequested(const QPoint &)), this, SLOT(InterfaceWorldMenu(const QPoint &)));
    
    //Update the RightClick Menu
    void ZoneEditor::WorldItemMenu(const QPoint &point)
    {
       // QModelIndex index = ui->TW_World->indexAt(point);
        qDebug() << "wassup dude";
    }
    

    What should be happening is whenever i rightclick an item, the console output should say "wassup dude" however there is no output. Instead i get this

    "QObject::connect: No such slot ZoneEditor::InterfaceWorldMenu(const QPoint &)"

    Which has what has got be stumped because i made InterfaceWorldMenu a slot so how can it not find it?

    Thanks!

    1 Reply Last reply
    0
    • RatzzR Offline
      RatzzR Offline
      Ratzz
      wrote on last edited by
      #2

      Your slot in the connect is InterfaceWorldMenu(const QPoint &)) but the slot you defined is InterfaceWorldMenu(const QPoint &))
      so the slot in connect should have been WorldItemMenu(const QPoint &point)

      --Alles ist gut.

      1 Reply Last reply
      2
      • C Offline
        C Offline
        Cysis145
        wrote on last edited by
        #3

        wow okay now i feel like an idiot. Having said that i've fixed that, and yet the signal is still not going through. If i right click there is no "wassup dude" output.

        jsulmJ 1 Reply Last reply
        0
        • RatzzR Offline
          RatzzR Offline
          Ratzz
          wrote on last edited by
          #4

          show me your code?

          --Alles ist gut.

          1 Reply Last reply
          0
          • C Cysis145

            wow okay now i feel like an idiot. Having said that i've fixed that, and yet the signal is still not going through. If i right click there is no "wassup dude" output.

            jsulmJ Offline
            jsulmJ Offline
            jsulm
            Lifetime Qt Champion
            wrote on last edited by
            #5

            @Cysis145 In such situations you should check what connect(...) returns:

            qDebug() << connect(ui->TW_World, SIGNAL(customContextMenuRequested(const QPoint &)), this, SLOT(InterfaceWorldMenu(const QPoint &)));
            

            If it returns false then the connection failed. And if the connection fails you actually should see a warning at runtime.

            https://forum.qt.io/topic/113070/qt-code-of-conduct

            1 Reply Last reply
            1

            • Login

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