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. How to remove the mapper's item?
QtWS25 Last Chance

How to remove the mapper's item?

Scheduled Pinned Locked Moved Unsolved General and Desktop
qt guisignalmapper
5 Posts 3 Posters 1.7k Views
  • 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.
  • E Offline
    E Offline
    Eng.Jason
    wrote on 24 May 2016, 08:41 last edited by
    #1

    Hello, I used a QSignalMapper for used to lot of button clicked() event.

    unfortunately, i can't find, how to remove the QSignalMapper's item.

    So, I use QSignalMapper Iike this.

    ------------------------------------main.cpp-------------------------------
    // in main.cpp
    #define COUNT 7
    QSignalMapper *mapper = new SignalMapper();
    
    QList<QPushButton *> mButtons ;
    
    //setting
    for(int i =0; i < COUNT; i++)
    {
       QPushButton *pbtn = new QPushButton( );
       mButtons.append(pbtn);
       
      connect(mButtons[i], SIGNAL(clicked()), mapper, SLOT(map()));
      mapper->setMapping(mButton[i], i); 
    }
    RemoveMap(3);
    
    -----------------------------------------------------------------------------
    
    void myclass::RemoveMap(int index)
    {
     // I want to know, how to remove mapper's item by index parameter.
     // I saw the removeMappings( ) function, but I couldn't guess the how to use it;..
    }
    
    I need your help. thank you.
    
    K 1 Reply Last reply 24 May 2016, 12:01
    0
    • S Offline
      S Offline
      SGaist
      Lifetime Qt Champion
      wrote on 24 May 2016, 08:52 last edited by
      #2

      Hi,

      Something like mapper->removeMapping(myButton[i]);

      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
      3
      • E Eng.Jason
        24 May 2016, 08:41

        Hello, I used a QSignalMapper for used to lot of button clicked() event.

        unfortunately, i can't find, how to remove the QSignalMapper's item.

        So, I use QSignalMapper Iike this.

        ------------------------------------main.cpp-------------------------------
        // in main.cpp
        #define COUNT 7
        QSignalMapper *mapper = new SignalMapper();
        
        QList<QPushButton *> mButtons ;
        
        //setting
        for(int i =0; i < COUNT; i++)
        {
           QPushButton *pbtn = new QPushButton( );
           mButtons.append(pbtn);
           
          connect(mButtons[i], SIGNAL(clicked()), mapper, SLOT(map()));
          mapper->setMapping(mButton[i], i); 
        }
        RemoveMap(3);
        
        -----------------------------------------------------------------------------
        
        void myclass::RemoveMap(int index)
        {
         // I want to know, how to remove mapper's item by index parameter.
         // I saw the removeMappings( ) function, but I couldn't guess the how to use it;..
        }
        
        I need your help. thank you.
        
        K Offline
        K Offline
        kshegunov
        Moderators
        wrote on 24 May 2016, 12:01 last edited by kshegunov
        #3

        @Eng.Jason
        To add to @SGaist, you seem to be using one mapper with multiple buttons, which will not work. A signal mapper will map a single signal, from a single object.

        EDIT: Disregard this completely wrong comment.

        Read and abide by the Qt Code of Conduct

        1 Reply Last reply
        1
        • S Offline
          S Offline
          SGaist
          Lifetime Qt Champion
          wrote on 24 May 2016, 21:26 last edited by
          #4

          @kshegunov Why will it not work ? AFAIK that's the goal of QSignalMapper: to map several objects to one signal with a parameter of known value.

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

          K 1 Reply Last reply 24 May 2016, 21:29
          0
          • S SGaist
            24 May 2016, 21:26

            @kshegunov Why will it not work ? AFAIK that's the goal of QSignalMapper: to map several objects to one signal with a parameter of known value.

            K Offline
            K Offline
            kshegunov
            Moderators
            wrote on 24 May 2016, 21:29 last edited by kshegunov
            #5

            @SGaist said:

            Why will it not work ? AFAIK that's the goal of QSignalMapper: to map several objects to one signal with a parameter of known value.

            I seem to have missed my morning coffee when I wrote that. Sure it will work.

            Read and abide by the Qt Code of Conduct

            1 Reply Last reply
            0

            1/5

            24 May 2016, 08:41

            • Login

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