Adding a text to the QTabWidget in c++

  • I have class which inherits QTabWidget. Inside the generated tab I want to display some text.The text should not be editable by the user.But during the application execution there can be a case/s which will cause the text change. Which class should I use for text? Thought about QTextEdit - but it doesn`t look like best idea - since the user should not change the text.Also thought about QTextLabel - but it also is not good - since the application displays text not label.

  • Why don't you just use QLabel?

  • You use QLabel and when you want to change the text you emit a signal, connect that signal to QLabel's setText slot and that should do it

  • Is QLabel is designed to update text dynamically?I am looking for the best option for displayed above functionality

  • Please be more specific about dynamically

  • The user can change modes or insert some input data for application,so the application execution changes:some values application calculates changes,some computation modes changes .
    These changes happen during the application execution and I may want to update the above data every several seconds.In the text (I am asking about) I want to report to the user about every such change

  • Well, whenever you want to update the data just emit the signal with the text you want... For example, let's say you have a signal updateStatus(QString). The user inputs something and you want to tell him "Hey, you just did something". (This is all assumed to be in your QTabWidget subclass)

    1st. connect(this, SIGNAL(updateStatus(QString)), tabLabel, SLOT(setText(QString)));

    2nd. emit updateStatus("Hey, you just did something");

    This should change your labels text yo Hey, you just did something.

Log in to reply

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