Comboxbox Signal & Slot problem



  • Hello,

    I want to set a Text into a Label if a specific value is chose in a combobox. This code dont works and I dont have any Idea how I can do this.

    @
    connect(ui->comboBoxPet, SIGNAL (activated(bunny)), this, SLOT (ui->label1->setText("bunny") ));
    connect(ui->comboBoxPet, SIGNAL (activated(dog)), this, SLOT (ui->label1->setText("dog") ));
    @

    Thank you :(


  • Lifetime Qt Champion

    Hi,

    Your connect statements are completely wrong. You can't pass parameters like that.

    Try that instead:
    @connect(ui->comboBoxPet, SIGNAL (activated(QString)), ui->label1, SLOT (setText(QString)));@

    And please, have a look at Qt's documentation about Signals and Slots


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.