Search code examples
qtstylesheetqgraphicsview

No border for widgets when porting from Qt 5.2 to Qt 5.3


I have a project in Qt. It contains few graphics view,buttons, frames and labels. In Qt 5.2 all these used to have a white border around them at run time. However now I have migrated to Qt 5.3 and these borders are not visible. I tried setting the style sheet by using setStyleSheet("border-color:rgb..") but still the white border around any of the objects is not visible.

Has Qt changed anything in this aspect?

Thank You.


Solution

  • You can set a style sheet and specify a selector to apply a border to specific items.

    ID selector:

    setStyleSheet("QFrame#myFrame{border: 2px solid white;}");
    

    To make this work you must set an object name to your object. This assumes that the object's name is myFrame.

    Class selector:

    setStyleSheet(".QFrame{border: 2px solid white;}");