Search code examples
c++qtuser-interfacestylesheetgroupbox

Make QGroupBox::title expand


image

Using a stylesheet I manage to set the background for the title element as shown in the image above (1.) using:

QGroupBox::title
{
    background-color: rgb(255, 255, 0);
    subcontrol-origin: margin;
    subcontrol-position: bottom center;
}

Now I want the title to expand to the maximum size of the hosting QGroupBox as shown in image 2.. How do I accomplish this?

Thanks!

Edit: I wish to do this using style sheets only.


Solution

  • It turns out my efforts to find a solution on Google failed due to incorrect search terms...

    http://www.qtcentre.org/threads/43232-customizing-QGroupbox-title purposed setting

    QGroupBox::title
    {
      padding-left: 2000px;
      padding-right: 2000px;
    }
    

    Not very pretty but at least It could be done using stylesheets only.