0

I would like to show another view of a QTreeView when I click on an item that is in another QTreeView. I already know what I have to show and how to do it but my problem is that I can't access my ui variables from this second QTreeView. The first one is setup in the MainWindow class (more specifically in it's init method) and the second one should be created in a method of the first QTreeView class called onClickedItem which is already created:

def onItemClicked(self) :
        from ui_interface_cdc import Ui_MainWindow

        ui = Ui_MainWindow()
        
        if self.currentIndex().isValid() :
            self.deselecteditem = self.selecteditem
            self.deselectedindex = self.selectedindex

            self.selecteditem = str(self.currentIndex().internalPointer()).split(',')
            self.selectedindex = self.currentIndex()


            if self.currentIndex().siblingAtColumn(1).data() == -1 :
                id = self.currentIndex().siblingAtColumn(2).data()
                
                self.dimensiontree : t_dimension = t_dimension(parent=None, id_piece=id)
                self.dimensiontree.clicked.connect(self.dimensiontree.onItemClicked)
                ui.verticalLayout_6.addWidget(self.dimensiontree)
                self.dimensiontree.charger_model()
                self.dimensiontree.show()

Because I can't access the MainWindow, I get this error:

AttributeError: 'Ui_MainWindow' object has no attribute 'verticalLayout_6'.

Do you have any idea to fix this error or an alternative please?

By the way, I tried to setup the ui but is there a window to put in the parentheses that will allow me to setup the ui?

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.