UI and other classes



  • In my mainwindow class, I have:
    [code]
    painter.drawText(this->width()-35-width,40,displayed);
    [/code]

    displayed is the string I'm drawing. I have another class, and in that other class I check if the string is valid, and if not,
    [code]
    else
    {
    main.invalidString();
    }
    [/code]

    Where main is an instance of the MainWindow.

    Using qDebug, it is called fine, and in invalidString() I do:
    [code]
    displayed = "Error: Invalid string";
    [/code]
    I then do
    [code]
    qDebug() << displayed;
    [/code]

    It prints Error: Invalid string, as expected.

    However, it continues to draw the previous text, and if I do qDebug displayed in a private slot, it still says the previous text.

    Can anyone help me?



  • Hi,

    It will be really helpful if you can provide some lines of your code, as it we are not able to figure out the main problem related to your code. Also, check in the paintEvent() function whether the QString displayed is still set to the previous text even after main.invalidString() is called. After changing the text value of displayed u can call repaint() function if required.


Log in to reply
 

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