<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  </head>
  <body text="#000000" bgcolor="#FFFFFF">
    <p>Maybe I don't really get it, I haven't looked at your code for
      real, but you are trying to navigate directories and files. If
      that is so, why don't you use a QFileSystemModel() (I think you'd
      have to use a QListView), it's easier.<br>
      Here's some code I had that might get you started (you go into a
      directory with a double click, a '..' entry symbolizes parent
      directory):<br>
---------------------------------------------------------------------<br>
      from pathlib import Path<br>
      <br>
      class FileSystemView(QListView):<br>
      <br>
          def __init__(self, iniDir=None, parent=None):<br>
              super(FileSystemView, self).__init__(parent)<br>
      <br>
              if not iniDir:<br>
                  iniDir = Path.cwd()<br>
      <br>
              self.fileModel = QFileSystemModel()<br>
              self.fileModel.setFilter(QDir.NoDot | QDir.Files |
      QDir.Dirs)<br>
              rootIndex = self.fileModel.setRootPath(str(iniDir))<br>
      <br>
              self.setModel(self.fileModel)<br>
              self.setRootIndex(rootIndex)<br>
              self.curDir = str(iniDir)<br>
      <br>
              self.setSelectionMode(QAbstractItemView.ExtendedSelection)<br>
      <br>
              self.doubleClicked.connect(self.fileDblClicked)<br>
      <br>
      <br>
          def fileDblClicked(self, index):<br>
              fm = self.fileModel<br>
              if fm.isDir(index):<br>
                  if Path(fm.filePath(index)).stem == '..':<br>
                      dirPath = fm.filePath(fm.parent(fm.parent(index)))<br>
                      rootIndex = fm.setRootPath(dirPath)<br>
                      self.setRootIndex(rootIndex)<br>
                      self.curDir = str(Path(fm.filePath(<br>
                                             
      self.currentIndex())).parent.parent)<br>
                  else:<br>
                      rootIndex = fm.setRootPath(fm.filePath(index))<br>
                      self.setRootIndex(rootIndex)<br>
                      self.curDir = fm.filePath(self.currentIndex())<br>
---------------------------------------------------------------------<br>
    </p>
    <br>
    <div class="moz-cite-prefix">On 09/04/18 23:01, Python3 Lover wrote:<br>
    </div>
    <blockquote type="cite"
cite="mid:CADJnhV5T_s1q5OFb=cusYVTtpEF5Yw9PrU8-mMEDOwbPp3Vamg@mail.gmail.com">
      <div dir="ltr">Hi,
        <div><br>
        </div>
        <div>I am trying to make a simple files app (or, file explorer
          app) and I am using the QTableWidget to Display the files and
          directories. When the user clicks an directory, I want the
          program to jump to that directory. I have used the
          QTableWidget.cellClicked signal, and it does not currently
          work.</div>
        <div><br>
        </div>
        <div>The signal part:</div>
        <div><font face="monospace">self.filesTable.connect(print)#self.updateUiCellClick)</font><br>
        </div>
        <div>Added <font face="monospace">print</font> instead of <font
            face="monospace">self.updateUiCellClick</font> for debugging
          purposes.</div>
        <div><font face="monospace"><br>
          </font></div>
        <div>Code (probably you do not need this):</div>
        <div>
          <div><font face="monospace">#!/usr/bin/python3</font></div>
          <div><font face="monospace"><br>
            </font></div>
          <div><font face="monospace">print('i Import Modules')</font></div>
          <div><font face="monospace">print(' | Import sys')</font></div>
          <div><font face="monospace">import sys</font></div>
          <div><font face="monospace">print(' | Import PyQt5.QtCore')</font></div>
          <div><font face="monospace">from PyQt5.QtCore import *</font></div>
          <div><font face="monospace">print(' | Import PyQt5.QtGui')</font></div>
          <div><font face="monospace">from PyQt5.QtGui import *</font></div>
          <div><font face="monospace">print(' | Import PyQt5.QtWidgets')</font></div>
          <div><font face="monospace">from PyQt5.QtWidgets import * #
              PyQt5 Support</font></div>
          <div><font face="monospace">print(' | Import os')</font></div>
          <div><font face="monospace">import os</font></div>
          <div><font face="monospace">print(' | Import
              subprocess.Popen') # For backward-compatibility</font></div>
          <div><font face="monospace">from subprocess import Popen, PIPE</font></div>
          <div><font face="monospace">print(' | Done')</font></div>
          <div><font face="monospace">print('i Define class Form')</font></div>
          <div><font face="monospace"><br>
            </font></div>
          <div><font face="monospace">class root(QMainWindow):</font></div>
          <div><font face="monospace"><br>
            </font></div>
          <div><font face="monospace">    def __init__(self,
              parent=None):</font></div>
          <div><font face="monospace">        '''self.__init__ -
              Initializes QMainWindow'''</font></div>
          <div><font face="monospace">        print('  self.__init__ -
              Initializes QMainWindow')</font></div>
          <div><font face="monospace">        super(root,
              self).__init__(parent)</font></div>
          <div><font face="monospace"><br>
            </font></div>
          <div><font face="monospace">        # Create Variables</font></div>
          <div><font face="monospace">        self.currentPath = '/'</font></div>
          <div><font face="monospace">        os.chdir(self.currentPath)</font></div>
          <div><font face="monospace">        self.currentItems =
              os.listdir()</font></div>
          <div><font face="monospace">        self.currentItemsLsProcess
              = Popen(['ls','-l'], stdout=PIPE, stderr=PIPE)</font></div>
          <div><font face="monospace">       
              self.currentItemsLsProcessResult =
              self.currentItemsLsProcess.communicate()</font></div>
          <div><font face="monospace">        if
              self.currentItemsLsProcessResult[1].decode('utf-8'):</font></div>
          <div><font face="monospace">           
              QMessageBox.warning(self,'Files - ls -l Error','ls -l
              responded with non-blank stderr.Error is shown
here:<br><code>{}</code><br><hr><br>Error
              LsStderr (e-lsstderr)<br><hr><br>If you
              want to support the team, go to the <a href="<a
                href="https://github.com/" moz-do-not-send="true">https://github.com/</a>">GitHub
Repository</a>.'.format(self.currentItemsLsProcessResult[1].decode('utf-8')))</font></div>
          <div><font face="monospace">        self.currentItemsLs =
              self.currentItemsLsProcessResult[0].decode('utf-8').split('\n')[1:-1]</font></div>
          <div><font face="monospace"><br>
            </font></div>
          <div><font face="monospace">        # Create Table Widget</font></div>
          <div><font face="monospace">        self.filesTable =
              QTableWidget()</font></div>
          <div><font face="monospace"><br>
            </font></div>
          <div><font face="monospace">        # Init Table Widget</font></div>
          <div><font face="monospace">        self.filesTable.clear()</font></div>
          <div><font face="monospace">       
self.filesTable.setSizeAdjustPolicy(QAbstractScrollArea.AdjustToContents)</font></div>
          <div><font face="monospace">       
              self.filesTable.setRowCount(len(self.currentItems))</font></div>
          <div><font face="monospace">       
              self.filesTable.setColumnCount(4)</font></div>
          <div><font face="monospace">       
              self.filesTable.setHorizontalHeaderLabels(['Name','TimeStamp','Type','ls
              -l'])</font></div>
          <div><font face="monospace">        #
              self.filesTable.setReadOnly(1)</font></div>
          <div><font face="monospace"><br>
            </font></div>
          <div><font face="monospace">        # Create & Add Items</font></div>
          <div><font face="monospace">        self.itemWidgets =
              [[],[],[],[]]</font></div>
          <div><font face="monospace">        for i in
              range(len(self.currentItems)):</font></div>
          <div><font face="monospace">           
              self.itemWidgets[0].append(QTableWidgetItem(self.currentItems[i]))</font></div>
          <div><font face="monospace">           
              self.filesTable.setItem(i,0,self.itemWidgets[0][-1])</font></div>
          <div><font face="monospace">           
              self.itemWidgets[3].append(QTableWidgetItem(self.currentItemsLs[i]))</font></div>
          <div><font face="monospace">           
              self.filesTable.setItem(i,3,self.itemWidgets[3][-1])</font></div>
          <div><font face="monospace"><br>
            </font></div>
          <div><font face="monospace">        # Init Widgets</font></div>
          <div><font face="monospace"><br>
            </font></div>
          <div><font face="monospace">        # Align Widgets to root</font></div>
          <div><font face="monospace">       
              self.setCentralWidget(self.filesTable)</font></div>
          <div><font face="monospace"><br>
            </font></div>
          <div><font face="monospace">        # Signals-and-Slots</font></div>
          <div><font face="monospace"><br>
            </font></div>
          <div><font face="monospace">        print('i Set self title')</font></div>
          <div><font face="monospace">       
              self.setWindowTitle('{}'.format(self.currentPath))</font></div>
          <div><font face="monospace"><br>
            </font></div>
          <div><font face="monospace">    def updateUi(self):</font></div>
          <div><font face="monospace">        '''self.updateUi - None'''</font></div>
          <div><font face="monospace">        os.chdir(self.currentPath)</font></div>
          <div><font face="monospace">        self.currentItems =
              os.listdir()</font></div>
          <div><font face="monospace">        self.currentItemsLsProcess
              = Popen(['ls','-l'], stdout=PIPE, stderr=PIPE)</font></div>
          <div><font face="monospace">       
              self.currentItemsLsProcessResult =
              self.currentItemsLsProcess.communicate()</font></div>
          <div><font face="monospace">        if
              self.currentItemsLsProcessResult[1].decode('utf-8'):</font></div>
          <div><font face="monospace">           
              QMessageBox.warning(self,'Files - ls -l Error','ls -l
              responded with non-blank stderr.Error is shown
here:<br><code>{}</code><br><hr><br>Error
              LsStderr (e-lsstderr)<br><hr><br>If you
              want to support the team, go to the <a href="<a
                href="https://github.com/" moz-do-not-send="true">https://github.com/</a>">GitHub
Repository</a>.'.format(self.currentItemsLsProcessResult[1].decode('utf-8')))</font></div>
          <div><font face="monospace">        self.currentItemsLs =
              self.currentItemsLsProcessResult[0].decode('utf-8').split('\n')[1:-1]</font></div>
          <div><font face="monospace">        self.filesTable.clear()</font></div>
          <div><font face="monospace">       
self.filesTable.setSizeAdjustPolicy(QtWidgets.QAbstractScrollArea.AdjustToContents)</font></div>
          <div><font face="monospace">       
              self.filesTable.setRowCount(len(self.currentItems))</font></div>
          <div><font face="monospace">       
              self.filesTable.setColumnCount(4)</font></div>
          <div><font face="monospace">       
              self.filesTable.setHorizontalHeaderLabels(['Name','TimeStamp','Type','ls
              -l'])</font></div>
          <div><font face="monospace">        self.itemWidgets =
              [[],[],[],[]]</font></div>
          <div><font face="monospace">        for i in
              range(len(self.currentItems)):</font></div>
          <div><font face="monospace">           
              self.itemWidgets[0].append(QTableWidgetItem(self.currentItems[i]))</font></div>
          <div><font face="monospace">           
              self.filesTable.setItem(i,0,self.itemWidgets[0][-1])</font></div>
          <div><font face="monospace">           
              self.filesTable..connect(print)#self.updateUiCellClick)</font></div>
          <div><font face="monospace">           
              self.itemWidgets[3].append(QTableWidgetItem(self.currentItemsLs[i]))</font></div>
          <div><font face="monospace">           
              self.filesTable.setItem(i,3,self.itemWidgets[3][-1])</font></div>
          <div><font face="monospace">       
              self.filesTable.resizeColumnsToContents()</font></div>
          <div><font face="monospace">       
              self.setWindowTitle('{}'.format(self.currentPath))</font></div>
          <div><font face="monospace"><br>
            </font></div>
          <div><font face="monospace">    def updateUiCellClick(self,
              row, column):</font></div>
          <div><font face="monospace">        '''self.updateUiCellClick
              - None'''</font></div>
          <div><font face="monospace">       
              print('self.updateUiCellClick - None')</font></div>
          <div><font face="monospace">        self.currentpath +=
              self.itemWidgets[0][row].text+'/'</font></div>
          <div><font face="monospace">        self.updateUi()</font></div>
          <div><font face="monospace"><br>
            </font></div>
          <div><font face="monospace">print(' | Done')</font></div>
          <div><font face="monospace"><br>
            </font></div>
          <div><font face="monospace">if __name__ == '__main__':</font></div>
          <div><font face="monospace">    print('i Execute instance')</font></div>
          <div><font face="monospace">    app = QApplication(sys.argv)</font></div>
          <div><font face="monospace">    root = root()</font></div>
          <div><font face="monospace">    root.show()</font></div>
          <div><font face="monospace">    app.exec_()</font></div>
          <div><font face="monospace">    print(' | Done')</font></div>
        </div>
        <div><font face="monospace"><br>
          </font></div>
        <div>Any help would be appreciated,</div>
        <div>Ken</div>
        <div><br>
        </div>
      </div>
      <br>
      <fieldset class="mimeAttachmentHeader"></fieldset>
      <br>
      <pre wrap="">_______________________________________________
PyQt mailing list    <a class="moz-txt-link-abbreviated" href="mailto:PyQt@riverbankcomputing.com">PyQt@riverbankcomputing.com</a>
<a class="moz-txt-link-freetext" href="https://www.riverbankcomputing.com/mailman/listinfo/pyqt">https://www.riverbankcomputing.com/mailman/listinfo/pyqt</a></pre>
    </blockquote>
    <br>
  </body>
</html>