Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    UI and other classes

    General and Desktop
    2
    2
    1135
    Loading More Posts
    • 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.
    • C
      cp133 last edited by

      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?

      1 Reply Last reply Reply Quote 0
      • S
        Sam last edited by

        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.

        1 Reply Last reply Reply Quote 0
        • First post
          Last post