0

I'm comfortable with C++ but brand new to Qt. I apologize for my ignorance as I'm sure this is a very simple question. I'd like to make a custom clickable widget, basically a push button that is just a black square with Qt designer, but don't have any idea on where to start.

EDIT: after fumbling around I think I'm an epsilon closer. I created a black_box.png file. In the resource browser I created a new resource and prefix, and added the black_box.png. Any advice from here?

roro
  • 931
  • 5
  • 21

1 Answers1

1

You have a few options for what you want to achieve.

  1. You can use custom painting to draw a new button that subclasses QPushButton, this is reasonably involved and provides a huge amount of flexibility to build it to your requirements.
  2. You can use Qt's stylesheets mechanism to style it, you can get more information on it here: http://doc.qt.io/qt-5/stylesheet.html
  3. Or you can set a QPixmap of your image to be a button icon, and size your button to match it, there's a good answer on how to do this on this question: How to set image on QPushButton?
Community
  • 1
  • 1
Nicholas Smith
  • 11,642
  • 6
  • 37
  • 55