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) :
    QLabel(parent)
    {
    setBackgroundRole(QPalette::Base);
    setAttribute(Qt::WA_PaintOnScreen);
    setAttribute(Qt::WA_NoSystemBackground);
    setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Ignored);
    setFrameShape(QFrame::NoFrame);
    setScaledContents(true);
    setMouseTracking(true);
    }@
    and the main window widget
    @ImageViewer::ImageViewer()
    {
    scrollArea = new QScrollArea;
    mapView = new MapView(scrollArea);
    scrollArea->setWidget(mapView);
    setCentralWidget(scrollArea);
    }@

    what is my mistake?

    !http://imageshack.us/photo/my-images/442/pic3o.png/(screenshot)!



  • QLabel has a methods:
    [code]
    setFrameShape()
    setFrameShadow()
    setLineWidth() // set to 0?
    setMidLineWidth()
    [/code]
    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......);
    label->setPixmap(QPixmap::fromImage(im));@
    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.