Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    [SOLVED] QSignalMapper and QComboBox

    General and Desktop
    2
    2
    3047
    Loading More Posts
    • 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.
    • D
      depecheSoul last edited by

      Hello. In the process of learning QSignalMapper, I wrote a some code out of my head, that has QComboBox, and QLabel. I have made a program that changes text in QLabel, when QComboBox is activated. The problem is that I only get the output of 4. QComboBox has values from 0 to 4.

      I think the problem is within this line of code:
      @
      mapper->setMapping(cBox, QString::number(f1));
      @
      because I didint set elements but only QComboBox. Is that any way that I can set signal mapping for individual values inside QComboBox.

      1 Reply Last reply Reply Quote 0
      • L
        lgeyer last edited by

        QSignalMapper is used to combine multiple signals from different widgets into one signal, for example if you want to change the text of a label from the values of multiple combo boxes.

        If you just want to set the label to the value of a combo box use the currentIndexChanged signal instead.
        @
        connect(comboBox, SIGNAL(currentIndexChanged(QString)), label, SLOT(setText(QString)));
        @

        In addition to the documentation you might read "this article":http://doc.trolltech.com/qq/qq10-signalmapper.html featuring the purpose and usage of QSignalMapper.

        1 Reply Last reply Reply Quote 0
        • First post
          Last post