Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. How do I remove white border around QScrollArea?
Forum Updated to NodeBB v4.3 + New Features

How do I remove white border around QScrollArea?

Scheduled Pinned Locked Moved General and Desktop
5 Posts 2 Posters 25.5k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R Offline
    R Offline
    Radical
    wrote on last edited by
    #1

    I'm trying to edit the source of an app called qcomicbook ( http://qcomicbook.linux-projects.net/ ), to remove an annoying 1px white border which persists in full-screen mode.

    First I tried changing the background of the main window black, but it had no effect. Here is the newly compiled app against the designer preview:

    !http://img413.imageshack.us/img413/4751/screenshot15j.png(screenshot)!

    I tried also setting some border and margin style information but the white border remained, so I looked at the cpp source, searched the Qt docs, and made a few simple edits, but they had no effect.

    At first I thought this would be a quick cosmetic fix, but now I assume the developer could not find the cause.

    He has this inside PageViewBase.cpp:

    @PageViewBase::PageViewBase(QWidget *parent, int physicalPages, const ViewProperties &props)
    : QScrollArea(parent)
    , m_physicalPages(physicalPages)
    , props(props)
    , smallcursor(NULL)
    {
    context_menu = new QMenu(this);
    connect(&this->props, SIGNAL(changed()), this, SLOT(propsChanged()));
    recalculateScrollSpeeds();

    }
    @

    This inside ContinuousPageView.cpp:

    @
    ContinuousPageView::ContinuousPageView(QWidget *parent, int physicalPages, const ViewProperties& props)
    : PageViewBase(parent, physicalPages, props)
    , m_firstVisible(-1)
    , m_firstVisibleOffset(0)
    , m_y1pos(NULL)
    , m_y2pos(NULL)
    {
    //setFocusPolicy(QWidget::StrongFocus);

    QWidget *w = new QWidget(this);
    

    // w->setColor(QPalette::Background, Qt::black);
    // adding above line didn't work
    //
    w->setSizePolicy(QSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding));
    m_layout = new QVBoxLayout(w);
    m_layout->setContentsMargins(0, 0, 0, 0);
    // changing above line didn't change anything
    m_layout->setSpacing(0);
    m_layout->setAlignment(Qt::AlignCenter);

    recreatePageWidgets();
    recalculatePageSizes();
    
    setWidget(w);
    setWidgetResizable(true);
    
    setBackground(props.background());
    setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Ignored);
    
    // track scrollbar range changes to restore its relative position
    connect(verticalScrollBar(), SIGNAL(rangeChanged(int, int)), this, SLOT(scrollbarRangeChanged(int, int)));
    

    }
    @

    And this inside ComicMainWindow.cpp:

    @
    void ComicMainWindow::setupComicImageView()
    {
    const int n = (sink != NULL ? sink->numOfImages() : 0);
    if (view)
    {
    view->disconnect();
    pageLoader->disconnect();
    view->deleteLater();
    }
    const ViewProperties props;
    if (cfg->continuousScrolling())
    {
    view = new ContinuousPageView(this, n, props);
    }
    else
    {
    view = new SimplePageView(this, n, props);
    }

    setCentralWidget(view);
    view->setFocus();
    
    reconfigureDisplay();
    
    connect(actionPageTop, SIGNAL(triggered(bool)), view, SLOT(scrollToTop()));
    ...
    

    }
    @

    Ideas?

    1 Reply Last reply
    0
    • T Offline
      T Offline
      tony
      wrote on last edited by
      #2

      Hi,

      QScrollArea is a QFrame descendant. If you set the frame shape to QFrame::NoFrame

      setFrameShape(QFrame::NoFrame);

      it should disappear ... did I understand your point?

      Tony.

      1 Reply Last reply
      5
      • R Offline
        R Offline
        Radical
        wrote on last edited by
        #3

        Tony, thanks, but this did not remove the border.

        In Qt, is QFrame the only class which has paints a border?

        James

        1 Reply Last reply
        0
        • T Offline
          T Offline
          tony
          wrote on last edited by
          #4

          Well, I'm not sure that's the only one. QFrame is a QWidget with a border, so I guess that any widget that'd like to be surrounded by a border, can descend directly from QFrame.

          Anyway, it's really strange that your border does not disappear. If you place a QScrollArea on a QWidget with Qt Designer, you can test it by yourself and it works (are you sure it's a QScrollArea???)

          I can just think about two causes:

          a) a particular stylesheet is present, and it draws a border. In this case, you should remove it there.
          b) it has a custom paint event. It shouldn't be so difficult to remove any suspicious drawRect inside that method.

          Tony.

          1 Reply Last reply
          0
          • R Offline
            R Offline
            Radical
            wrote on last edited by
            #5

            Ok, setFrameShape did work actually. The other day I was running make from vi in the wrong dir.

            Thanks for the help.

            James.

            1 Reply Last reply
            0

            • Login

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • Users
            • Groups
            • Search
            • Get Qt Extensions
            • Unsolved