Can you hide a QGroupBox frame but preserve it's content visible?

jpo38 picture jpo38 · Apr 13, 2016 · Viewed 10.1k times · Source

I have a QGroupBox. Depending on the context, it's title may be redundent (displayed in another place of the GUI), so I then need to make as if the QGroupBox was not here....but I must preserve it's content visible (so I don't want to call QGroupBox::hide())!

I need to do this dynamically at runtime and would like to avoid creating/destroying the QGroupBox + reparenting it's content....there must be an easier way to do this.

What I tried so far:

QGroupBox visible:

enter image description here

  • QGroupBox::setTitle("") removes the text.
  • QGroupBox::setFlat(true) makes the frame be a single line.

I end up with this:

enter image description here

Not too bad...but a line remains....is there a way to completely hide the QGroupBox frame but preserve it's content visible?

Answer

pablo_worker picture pablo_worker · Feb 27, 2017

My option:

QGroupBox theBox;
theBox.setFlat(true);
theBox.setStyleSheet("border:0;");