Congratulations to our 2022 Qt Champions!

[solved] Removing borders

  • Hello
    I'm new to -QT- Qt and would have a following question.

    I've developed a simple widget that only consists of a label with a pixmap set to it, attached to a QBoxLayout combined with some functions. I'm trying to get it to cover the whole screen in an embedded device, but when I show it there are narrow borders around the picture set to the label. I tried removes these with the following line

    a.setStyleSheet("* {margin: 0px;border:0px;padding:0px;}");

    without any success. Could you please advice me how to display the picture to cover the complete screen area? The widget is showed on its own, not attached to a mainwindow. Thank you!
    Best regards

  • richard,

    wat is a?


  • Hi ThaRez,

    Welcom to the devnet forums.

    A similar question has been asked before. The solution is you draw on border-image using a stylesheet.
    If you have a look in "the following topic":, you will see all the details and links to the docs that describe why it is like that.

  • Hello
    Thank you for the responses! Sorry for not being clear, a is the QApplication

    QApplication a(argc, argv);

    I manage to get it working, the magic was the following line:

    mainLayout->setContentsMargins(0, 0, 0, 0);

    applied to the QVBoxLayout to which the label was added.
    Best regards

  • We are glad you solved it. thanks for letting us know and showing the solution so others can benefit from it.

    Could you please edit your title and ad [solved] in front of it? This is a workaround.
    A better solution is in the making for marking a topic as solved.

Log in to reply