Results 1 to 1 of 1

Thread: Qt - delete space between qscrollbar and qabstractscrollarea

  1. #1
    Join Date
    May 2015
    Posts
    1
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows

    Unhappy Qt - delete space between qscrollbar and qabstractscrollarea

    I have a custom-drawn scrollbar and I'm trying to eliminate some space between a qscrollbar and qabstractscrollarea, this is my code:

    MainWindow

    Qt Code:
    1. MainWindow::MainWindow(QWidget *parent) :
    2. QMainWindow(parent),
    3. ui(new Ui::MainWindow)
    4. {
    5. ui->setupUi(this);
    6.  
    7.  
    8.  
    9. // Create the scrollarea control
    10. CTE* scrollarea = new CTE(this);
    11. ui->here->addWidget( scrollarea);
    12. }
    To copy to clipboard, switch view to plain text mode 

    The scrollarea control

    Qt Code:
    1. class CTE : public QAbstractScrollArea {
    2. Q_OBJECT
    3. public:
    4. explicit CTE(QWidget *parent = 0);
    5.  
    6. };
    7.  
    8. CTE::CTE(QWidget *parent) :
    9. {
    10.  
    11. scr *m_verticalScrollBar = new scr( );
    12. this->setVerticalScrollBar( m_verticalScrollBar);
    13. this->setVerticalScrollBarPolicy( Qt::ScrollBarAlwaysOn );
    14.  
    15. this->setFrameStyle(1);
    16.  
    17. // Debug code (see image below)
    18. static_cast<QWidget*>(this->verticalScrollBar()->parent()->parent())->setStyleSheet("QWidget { background-color: red; }");
    19. static_cast<QWidget*>(this->verticalScrollBar()->parent())->setStyleSheet("QWidget { background-color: black; }");
    20. }
    To copy to clipboard, switch view to plain text mode 

    and the scrollbar

    Qt Code:
    1. class scr : public QScrollBar
    2. {
    3. public:
    4. scr();
    5. };
    6.  
    7. scr::scr() :
    8. {
    9.  
    10. }
    To copy to clipboard, switch view to plain text mode 


    This is the result and the area I'm trying to eliminate



    I can't understand how to get rid of it and especially **who owns that part**. Is it a container that contains my scrollbar and which is a subwidget of MyControl? I have no idea

    Can somebody help me out please? I'm using Qt5 on linux and this problem **doesn't show up in Windows with the same exact code**
    Last edited by mark28; 24th May 2015 at 14:07. Reason: updated contents

Similar Threads

  1. QLineEdit shows always the end, how shows start ?
    By Alundra in forum Qt Programming
    Replies: 8
    Last Post: 19th June 2015, 13:09
  2. set left and right margin for QGridLayout
    By anbu01 in forum Newbie
    Replies: 0
    Last Post: 28th October 2014, 06:58
  3. Replies: 1
    Last Post: 15th July 2011, 07:49
  4. Scrollbar on the left
    By torn in forum Qt Programming
    Replies: 5
    Last Post: 14th September 2009, 10:22
  5. scrollbar on left side of qtextedit
    By piotrek in forum Qt Programming
    Replies: 1
    Last Post: 15th February 2008, 22:07

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.