I have a custom QWidget class that does not seem to be inheriting its parent's stylesheet as I understand it should. I print out the parent stylesheet in my custom class's constructor and it's definitely the correct parent with the correct stylesheet.
MyWidget::MyWidget(QWidget *parent_) :
QWidget(parent_)
{
std::cout << "parent is " << parent_->objectName().toStdString() << std::endl;
std::cout << "stylesheet is: " << parent_->styleSheet().toStdString() << std::endl;
However, I found I can get it to work If I call this in the constructor:
setStyleSheet(parent_->styleSheet());
My understanding is that this should not be necessary. It doesn't seem to be required for other widgets in my program. What could I be doing wrong that would prevent this from working?