How to remove black border around widget?

  • Hello,
    I am writing Qt application under Linux for displaing electronic maps. After drawing onto QLabel and resizing window I have a black border around QLabel (before resizing everything is fine).
    I am drawing bitmap with Xlib function XPutImage to speed-up drawing

    @void MapView::paintEvent(QPaintEvent *)
    GC context = XCreateGC(QX11Info::display(), winId(), 0, NULL);
    XPutImage(QX11Info::display(), winId(), context, scr->ximage, 0, 0, 0, 0, scr->W, scr->H);
    XFreeGC(QX11Info::display(), context);

    @MapView::MapView(QWidget *parent) :
    setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Ignored);
    and the main window widget
    scrollArea = new QScrollArea;
    mapView = new MapView(scrollArea);

    what is my mistake?


  • QLabel has a methods:
    setLineWidth() // set to 0?
    maybe this will help you.

  • Have you tried drawing bitmap with Qt?

  • to Hostel:
    these methods did not made any effect
    I think that problem is bit deeper inside the Qt

    to Kxyu:
    I am trying to draw bitmap with XPutImage.
    All is right when i am drawing bitmap with
    @QImage im(bitmap, width, height, Q_RGBA......);
    but it is too slow for me

  • As I understand, the problem is with custom painting in painEvent() and property Qt::WA_NoSystemBackground - without this property there is no black border but after my painting by XPutImage() my qLabel widget immidiately repaints with background color

  • Create a style with a 0 border width and call setStyleSheet.

  • setStyleSheet("QLabel {border: 0px;}") + custom paintEvent causes an internal error

  • Where are you setting the stylesheet? In the MapView constructor? Not sure why a custom paintEvent would get in the way. We do it all of the time but without the custom paintEvent.

  • I have tryed both - inside constructor and outside.
    Another variant is to draw bitmap with OpenGL and GLWidget
    @glDrawPixels(scr->W, scr->H, GL_BGRA, GL_UNSIGNED_BYTE, (const GLvoid *)scr->bitmap);@
    and the same effect - black border around my GLWidget. I am in frustration!)

  • I think that Qt QScroll area works wrong - I have reimplemented it and had no problems with borders!

Log in to reply

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.