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. [SOLVED] QSignalMapper and QComboBox
QtWS25 Last Chance

[SOLVED] QSignalMapper and QComboBox

Scheduled Pinned Locked Moved General and Desktop
2 Posts 2 Posters 3.2k 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.
  • D Offline
    D Offline
    depecheSoul
    wrote on last edited by
    #1

    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
    0
    • L Offline
      L Offline
      lgeyer
      wrote on last edited by
      #2

      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
      0

      • Login

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