@2hours said in Problem with tableWidget component when QGraphicsOpacityEffect gradient reverts to opacity:
When I use QGraphicsOpacityEffect to implement a gradient toggle for stackedWidgets, the tablewidget component on page 0 of the stackedWidget is not being restored to opacity properly, as indicated by the fact that its center background is restored to opacity but the column headers and sliders are transparent.
I'm not sure, can you show or explain further what you expect?
I don't know what
it immediately reverts to opacity
means, but some things I've noticed:
This line is meaningless
ui->tableWidget->setGraphicsEffect(nullptr);
since these lines
QWidget *currentWidget = ui->stackedWidget->currentWidget();
// ...
QWidget *nextWidget = ui->stackedWidget->widget(0);
return a plain "page" QWidget which holds your QTableWidget. So the QGraphicsOpacityEffect is applied to the page Widget, not the QTableView itself.
(when you did everything in Designer)
Also there might be something wrong with your logic... if you want to do what I think, then starting both animations at the same time and with same duration doesn't make any sense.
Start the Fade-out, when finished, start the fade-in and flip the page of your QStackedWidget.
It works for me, but some parts of the QTableWidget seem to ignore the opacity effect at all... they are never opaque or transparent. The background of the header and other widgets on the same page fade-in though.
Edit:
When setting the effect to the QTableWidget's viewport, the content fades in correctly (the header still doesn't)
Seems like QTableWidget doesn't like being transparent :D
Even though, setting the effect to the QStackedWidget' s page widget, should apply it to all children (as stated here)