When I was using QGridLayout to display my widgets, only the widget was shown and the part of the image that was transparent was not shown. Now I switched to using QGraphicsScene and QGraphicsView, and now my images have a gray background wherever they used to be transparent.
Qt Code:
  1. void Piece::paintEvent(QPaintEvent *)
  2. {
  3. string image = ":/images/" + color + piece + ".png";
  4. pixmap.load(image.c_str());
  5. //pixmap.setMask(pixmap.createMaskFromColor(QColor(240, 240, 240)));
  6.  
  7. QPainter paint(this);
  8. paint.drawPixmap(0, 0, pixmap);
  9. }
To copy to clipboard, switch view to plain text mode 
That's how the image is displayed on my widget. When I used the code,
Qt Code:
  1. layout->addWidget(0,0,1,1);
To copy to clipboard, switch view to plain text mode 
the background is transparent. But when I use,
Qt Code:
  1. scene->addWidget(piece);
To copy to clipboard, switch view to plain text mode 
The widget has a gray background. How can I make it transparent? The full code can be found here if necessary (probably won't be necessary): https://github.com/gsingh93/Chess