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. QSignalMapper not working.
Qt 6.11 is out! See what's new in the release blog

QSignalMapper not working.

Scheduled Pinned Locked Moved General and Desktop
4 Posts 3 Posters 2.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.
  • ? Offline
    ? Offline
    A Former User
    wrote on last edited by
    #1

    Hi, i use QSignalMapper like this:
    @
    class MainWindow;
    }

    class MainWindow : public QMainWindow
    {
    Q_OBJECT

    public:
    explicit MainWindow(QWidget *parent = 0);
    ~MainWindow();
    public slots:
    void cclick(int);

    private:
    Ui::MainWindow *ui;
    QSignalMapper *signalmaper;
    };@
    in constructor:
    @
    signalmaper = new QSignalMapper(this);
    connect(signalmaper, SIGNAL(mapped(int)),this,SLOT(cclick(int)));
    ui->setupUi(this);
    signalmaper->setMapping(ui->pushButton,10);
    @

    @void MainWindow::cclick(int x)
    {

    ui->pushButton->setText("dfdff");
    

    }
    @
    but when i click on button nothing happen. any idea?

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      Did you check that the slot was called ? With i.e the debugger or simply a

      @qDebug() << Q_FUNC_INFO;@

      in cclick ?

      What's the original text of pushButton ?

      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
      • ? Offline
        ? Offline
        A Former User
        wrote on last edited by
        #3

        the slot not called. this is application output:
        @

        Debugging starts
        Temporarily disabling breakpoints for unloaded shared library "C:\Qt\Qt5.0.1\5.0.1\mingw47_32\plugins\platforms\qminimald.dll"
        Temporarily disabling breakpoints for unloaded shared library "C:\Qt\Qt5.0.1\5.0.1\mingw47_32\plugins\platforms\qwindowsd.dll"
        MainWindow::MainWindow(QWidget*)
        @

        1 Reply Last reply
        0
        • ? Offline
          ? Offline
          A Former User
          wrote on last edited by
          #4

          You are missing a connect statement:
          @
          connect(ui->pushButton, SIGNAL(clicked()),signalmaper,SLOT(map()));
          @

          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