Get the string from one class and display it in another class - C++



  • Hello
    I am new to Qt and I am trying to get a string which is displayed in class x to be also displayed in class y
    I have this code in class x
    @QString display(QString::number("Some info");
    ui->tempLabel->setText(display);@

    which returns "some info" , now I created another class
    @void MainWindow: Button @

    and I want to display that string in that class

    can someone please help ?
    thanks


  • Moderators

    you have to provide more info.
    Especially about
    @void MainWindow: Button @
    Whats the exact base class of it?

    Since it's a button i can guess that is a QPushButton or a QToolButton, right? If so you can also use setText on it.



  • [quote author="raven-worx" date="1380522610"]you have to provide more info.
    Especially about
    @void MainWindow: Button @
    Whats the exact base class of it?

    Since it's a button i can guess that is a QPushButton or a QToolButton, right? If so you can also use setText on it.[/quote]

    Yes, that is a Qt push button , similar to :
    @void MainWindow::on_pushButton_clicked()
    {
    ui->label->setText("The String");
    // QString display(QString::number("Some info");
    }
    @
    so basically, when that button is pressed, the string from the first class is shown


Log in to reply
 

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