python - About QTreeView and change selected index -


i use pyqt5.

i use qtreeview qdirmodel list files , folders.

self.dirmodel = qtwidgets.qdirmodel(self) self.dirtreeview = qtwidgets.qtreeview() self.dirtreeview.setmodel(self.dirmodel) 

i want add button change selected index, example, when press button, can select next file in current folder, behavior same press "down" key.

what should do?

you need add button gui, , connect slot clicked event.

 self.button = qtgui.qpushbutton('test', self)         self.button.clicked.connect(self.handlebutton)         // layout existing 1         layout = qtgui.qvboxlayout(self)         layout.addwidget(self.button)      def handlebutton(self):         print ('hello world') 

then when have need write code in handlebutton function updates index. qtreeview allows access rows, need row counter , every time increment , ask next row in tree:

indexitem = self.model.index(index.row(), 0, index.parent())  filename = self.model.filename(indexitem) filepath = self.model.filepath(indexitem) 

Comments

Popular posts from this blog

get url and add instance to a model with prefilled foreign key :django admin -

css - Make div keyboard-scrollable in jQuery Mobile? -

ruby on rails - Seeing duplicate requests handled with Unicorn -