Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. UI and other classes
QtWS25 Last Chance

UI and other classes

Scheduled Pinned Locked Moved General and Desktop
2 Posts 2 Posters 1.3k Views
  • 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 Offline
    C Offline
    cp133
    wrote on last edited by
    #1

    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
    0
    • S Offline
      S Offline
      Sam
      wrote on last edited by
      #2

      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
      0

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved