Problem while scrolling in QTreeWidget



  • Hi everyone...

    I want to show QWidget in QTreeWidget. Everything works fine. When the no. of widgets exceeds then the Vertical ScrollBar appears. But, when i scroll down, widgets does not move. Texts is moving but widget is not. Following is my code:-

    @class Widget : public QWidget
    {
    Q_OBJECT

    public:
    Widget(QWidget *parent = 0);
    ~Widget();

    private:
    Ui::Widget *ui;

    QTreeWidgetItem* treeItem;
    
    QList<QTreeWidgetItem*> itemList;
    QList<QTreeWidgetItem*> widgetList;
    
    QTreeWidgetItem* item;
    QTreeWidgetItem* BtnItem;
    
    QPushButton* btn;
    

    };@

    @Widget::Widget(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::Widget)
    {
    ui->setupUi(this);

    treeItem = new QTreeWidgetItem();
    treeItem->setText(0,"Tree");
    
    ui->treeWidget->insertTopLevelItem(0,treeItem);
    
    
    for(int i=0; i<50; i++)
    {
        item = new QTreeWidgetItem();
        QString val = QString::number(i);
        item->setText(0,"Child" + val);
        treeItem->addChild(item);
    
        BtnItem = new QTreeWidgetItem();
        btn = new QPushButton(val);
    
        treeItem->addChild(BtnItem);
        ui->treeWidget->setItemWidget(BtnItem,0,btn);
    
    }
    

    }

    Widget::~Widget()
    {
    delete ui;
    }
    @

    Thanks in advance..... :)


Log in to reply
 

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