Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

QDockWidget: how to have scroll feature



  • Hi,
    I have many dock widgets placed in bottom dock area of my screen. Now i need to have horizontal scrollbar feature for this bottom dock area. How to get one?

    Any ideas...?
    i had set horizontal scrollbar policy to alwayson. it displays scrollbar but it is not active

        scra1 = new QScrollArea;
        
            scra1->setBackgroundRole(QPalette::Light);
        
        
        
            lrupwr1 = new LRUPwrWgt;
        
            lrupwr1->setFixedSize(200, 100);
        
            lrupwr1->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
        
        
        
            lrupwr2 = new LRUPwrWgt;
        
            lrupwr2->setFixedSize(200, 100);
        
            lrupwr2->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
        
        
        
            lrupwr3 = new LRUPwrWgt;
        
            lrupwr3->setFixedSize(200, 100);
        
            lrupwr3->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
        
        
        
            hbx1 = new QHBoxLayout;
        
            hbx1->addWidget(lrupwr1, 1, Qt::AlignLeft);
        
            hbx1->addWidget(lrupwr2, 1, Qt::AlignLeft);
        
            hbx1->addWidget(lrupwr3, 1, Qt::AlignLeft);
        
            hbx1->addStretch(0);
        
        
        
            scra1->setLayout(hbx1);
        
            scra1->setWidgetResizable(false);
        
            scra1->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOn);
        
        
        
            // LRU1 POWER DOCKING WINDOW
        
            dw1 = new QDockWidget(tr("SMFD1Power"), this);
        
            dw1->setAllowedAreas(Qt::BottomDockWidgetArea);
        
            dw1->setWidget(scra1);
        
            addDockWidget(Qt::BottomDockWidgetArea, dw1);
        
            dw1->show();
    

    Untitled.png



  • Finally i am replying sol to my own problem.... after many tries....

        ui->setupUi(this);
    
        lrupwr1 = new LRUPwrWgt;
        lrupwr1->setFixedSize(200, 100);
        lrupwr1->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
    
        lrupwr2 = new LRUPwrWgt;
        lrupwr2->setFixedSize(200, 100);
        lrupwr2->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
    
        lrupwr3 = new LRUPwrWgt;
        lrupwr3->setFixedSize(200, 100);
        lrupwr3->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
    
        hbx1 = new QHBoxLayout;
        hbx1->addWidget(lrupwr1, 1, Qt::AlignLeft);
        hbx1->addWidget(lrupwr2, 1, Qt::AlignLeft);
        hbx1->addWidget(lrupwr3, 1, Qt::AlignLeft);
        hbx1->addStretch(0);
        wgt1 = new QWidget();
        wgt1->setLayout(hbx1);
    
        // LRU1 POWER DOCKING WINDOW
        dw1 = new QDockWidget(tr("SMFD1Power"), this);
        dw1->setAllowedAreas(Qt::BottomDockWidgetArea);
    
    
        scra1 = new QScrollArea;
        scra1->setHorizontalScrollBarPolicy( Qt::ScrollBarAlwaysOn );
        scra1->setWidgetResizable( true );
        scra1->setGeometry( 10, 10, 200, 100 );
        scra1->setWidget(wgt1);
    
        dw1->setWidget(scra1);
        addDockWidget(Qt::BottomDockWidgetArea, dw1);
        dw1->show();
    

    Well... thank you all and Qt. i think there's a lot to learn ...still.


Log in to reply