Planned maintenance has been done but it did not solve the problem. So work will continue on this and a new time for trying updates will be announced asap.

Change StackedWidget Pages With TreeWidget

  • Hello,
    I Have a StackedWidget and TreeWidget in my Window
    I Want to Connect this Two Object,
    And I Wrote This Codes But None Of This Codes Worked!
    My Codes:

    #include "management_menu.h"
    #include "ui_management_menu.h"
    management_menu::management_menu(QWidget *parent) :
        ui(new Ui::management_menu)
        delete ui;

    What i must do?

  • @M4RZB4Ni

    the signal and slot parameter does not match. Try to write your own slot then call stackwidget methods.

    example :

    connect(ui->treeWidget,SIGNAL(itemActivated(QTreeWidgetItem*,int)), this, SLOT(myslot(QTreeWidgetItem*,int)));
    in my slot:
    void management_menu::mySlot(QTreeWidgetItem*,int index) 

    This should work.

  • @c.savur
    this works but
    No more than once
    in Second click this those not work!

  • @M4RZB4Ni

    Yes, you are right it will work only one timer because, itemActivated(QTreeWidgetItem*,int), the second parameter is column id. So this will be same for the entire column.

    One way to do is that set some information to QTreeWidgetItem and in myslot use this information to call stackedWidget methods.

        QTreeWidgetItem *s = new QTreeWidgetItem();
    // set data
        s->setData(0, Qt::UserRole, QVariant("1"));
    // obtain data   
        QVariant data = s->data(0, Qt::UserRole);