Qt Code:
  1. QDir dir(qApp->applicationDirPath());
  2. dir.cd("icons");
  3. auto cellX = this->parentWidget()->width() / 100;
  4. auto cellY = this->parentWidget()->height() / 100;
  5.  
  6. QImage icon(dir.absoluteFilePath(m_viewModel.icon));
  7. QImage scaled = icon.scaledToHeight(cellY * 20, Qt::SmoothTransformation);
To copy to clipboard, switch view to plain text mode 

You don't want to do this in a paint event. Do it in a resize event and store the scaled image as a member variable. It's a complete waste of time to re-scale the image every time you draw it when the window size hasn't changed. It just slows your GUI down. And why are you repeatedly reading the icon from the file. Read it once and save it in a member variable.

As for your code, I don't know what you are trying to do. You are scaling your image so the height is 40% of the parent window's height, then you are drawing it at a position 20% of both width and height. What are you expecting to see?

Why are you using the parent widget and not the current widget (this) itself? Is the parent widget what you think it is?