Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt for Python
  4. PyQT4 App
Forum Updated to NodeBB v4.3 + New Features

PyQT4 App

Scheduled Pinned Locked Moved Unsolved Qt for Python
42 Posts 4 Posters 10.0k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Mitko

    @jsulm

    I change it, but now i have this:

     C:\xbee-gui-master\PyQT\Scripts\python.exe C:/xbee-gui-master/MainForm.py
    Traceback (most recent call last):
      File "C:/xbee-gui-master/MainForm.py", line 360, in <module>
        main()
      File "C:/xbee-gui-master/MainForm.py", line 355, in main
        bl = Block()
      File "C:/xbee-gui-master/MainForm.py", line 26, in __init__
        self.setWindowIcon(QtWidgets.QGui("zigbee.png"))
    AttributeError: module 'PyQt5.QtWidgets' has no attribute 'QGui'
    
    jsulmJ Offline
    jsulmJ Offline
    jsulm
    Lifetime Qt Champion
    wrote on last edited by
    #14

    @Mitko said in PyQT4 App:

    PyQt5.QtWidgets' has no attribute 'QGui'

    I did not suggest to write QtWidgets.QGui but PyQt5.QtGui

    https://forum.qt.io/topic/113070/qt-code-of-conduct

    M 1 Reply Last reply
    0
    • jsulmJ jsulm

      @Mitko said in PyQT4 App:

      PyQt5.QtWidgets' has no attribute 'QGui'

      I did not suggest to write QtWidgets.QGui but PyQt5.QtGui

      M Offline
      M Offline
      Mitko
      wrote on last edited by
      #15

      @jsulm

       C:\xbee-gui-master\PyQT\Scripts\python.exe C:/xbee-gui-master/MainForm.py
      Traceback (most recent call last):
        File "C:/xbee-gui-master/MainForm.py", line 360, in <module>
          main()
        File "C:/xbee-gui-master/MainForm.py", line 355, in main
          bl = Block()
        File "C:/xbee-gui-master/MainForm.py", line 26, in __init__
          self.setWindowIcon(PyQt5.QGui("zigbee.png"))
      NameError: name 'PyQt5' is not defined 
      
      jsulmJ 1 Reply Last reply
      0
      • M Mitko

        @jsulm

         C:\xbee-gui-master\PyQT\Scripts\python.exe C:/xbee-gui-master/MainForm.py
        Traceback (most recent call last):
          File "C:/xbee-gui-master/MainForm.py", line 360, in <module>
            main()
          File "C:/xbee-gui-master/MainForm.py", line 355, in main
            bl = Block()
          File "C:/xbee-gui-master/MainForm.py", line 26, in __init__
            self.setWindowIcon(PyQt5.QGui("zigbee.png"))
        NameError: name 'PyQt5' is not defined 
        
        jsulmJ Offline
        jsulmJ Offline
        jsulm
        Lifetime Qt Champion
        wrote on last edited by
        #16

        @Mitko said in PyQT4 App:

        PyQt5.QGui("zigbee.png")

        What is this?! You want to use QIcon, right?
        It should be I guess

        QtGui.QIcon("zigbee.png")
        

        It is also shown in the documentation which you should consult: https://doc.qt.io/qtforpython-5/PySide2/QtGui/QIcon.html

        https://forum.qt.io/topic/113070/qt-code-of-conduct

        M 1 Reply Last reply
        0
        • jsulmJ jsulm

          @Mitko said in PyQT4 App:

          PyQt5.QGui("zigbee.png")

          What is this?! You want to use QIcon, right?
          It should be I guess

          QtGui.QIcon("zigbee.png")
          

          It is also shown in the documentation which you should consult: https://doc.qt.io/qtforpython-5/PySide2/QtGui/QIcon.html

          M Offline
          M Offline
          Mitko
          wrote on last edited by
          #17

          @jsulm

           C:\xbee-gui-master\PyQT\Scripts\python.exe C:/xbee-gui-master/MainForm.py
          Traceback (most recent call last):
            File "C:/xbee-gui-master/MainForm.py", line 360, in <module>
              main()
            File "C:/xbee-gui-master/MainForm.py", line 355, in main
              bl = Block()
            File "C:/xbee-gui-master/MainForm.py", line 26, in __init__
              self.setWindowIcon(QtGui.QIcon("zigbee.png"))
          NameError: name 'QtGui' is not defined 
          
          jsulmJ 1 Reply Last reply
          0
          • M Mitko

            @jsulm

             C:\xbee-gui-master\PyQT\Scripts\python.exe C:/xbee-gui-master/MainForm.py
            Traceback (most recent call last):
              File "C:/xbee-gui-master/MainForm.py", line 360, in <module>
                main()
              File "C:/xbee-gui-master/MainForm.py", line 355, in main
                bl = Block()
              File "C:/xbee-gui-master/MainForm.py", line 26, in __init__
                self.setWindowIcon(QtGui.QIcon("zigbee.png"))
            NameError: name 'QtGui' is not defined 
            
            jsulmJ Offline
            jsulmJ Offline
            jsulm
            Lifetime Qt Champion
            wrote on last edited by
            #18

            @Mitko said in PyQT4 App:

            name 'QtGui' is not defined

            You of course have to import this module like any other module

            https://forum.qt.io/topic/113070/qt-code-of-conduct

            M 1 Reply Last reply
            0
            • jsulmJ jsulm

              @Mitko said in PyQT4 App:

              name 'QtGui' is not defined

              You of course have to import this module like any other module

              M Offline
              M Offline
              Mitko
              wrote on last edited by
              #19

              @jsulm
              Via Interpreter ? I've try, it seems to installed, but i've got same error

              jsulmJ 1 Reply Last reply
              0
              • M Mitko

                @jsulm
                Via Interpreter ? I've try, it seems to installed, but i've got same error

                jsulmJ Offline
                jsulmJ Offline
                jsulm
                Lifetime Qt Champion
                wrote on last edited by
                #20

                @Mitko said in PyQT4 App:

                Via Interpreter ?

                Don't know what you mean.

                from PyQt5 import QtGui
                

                https://forum.qt.io/topic/113070/qt-code-of-conduct

                M 1 Reply Last reply
                0
                • jsulmJ jsulm

                  @Mitko said in PyQT4 App:

                  Via Interpreter ?

                  Don't know what you mean.

                  from PyQt5 import QtGui
                  
                  M Offline
                  M Offline
                  Mitko
                  wrote on last edited by
                  #21

                  @jsulm
                  Thank you, i fix this

                  But now i have this:

                   Traceback (most recent call last):
                    File "C:/xbee-gui-master/MainForm.py", line 360, in <module>
                      main()
                    File "C:/xbee-gui-master/MainForm.py", line 355, in main
                      bl = Block()
                    File "C:/xbee-gui-master/MainForm.py", line 28, in __init__
                      self.centralWidgetLayout = QtGui.QVBoxLayout(self.centralWidget)
                  AttributeError: module 'PyQt5.QtGui' has no attribute 'QVBoxLayout'
                  
                  
                  jsulmJ 1 Reply Last reply
                  0
                  • M Mitko

                    @jsulm
                    Thank you, i fix this

                    But now i have this:

                     Traceback (most recent call last):
                      File "C:/xbee-gui-master/MainForm.py", line 360, in <module>
                        main()
                      File "C:/xbee-gui-master/MainForm.py", line 355, in main
                        bl = Block()
                      File "C:/xbee-gui-master/MainForm.py", line 28, in __init__
                        self.centralWidgetLayout = QtGui.QVBoxLayout(self.centralWidget)
                    AttributeError: module 'PyQt5.QtGui' has no attribute 'QVBoxLayout'
                    
                    
                    jsulmJ Offline
                    jsulmJ Offline
                    jsulm
                    Lifetime Qt Champion
                    wrote on last edited by
                    #22

                    @Mitko said in PyQT4 App:

                    QVBoxLayout

                    Please do also some research on your own!
                    If you google for QVBoxLayout you will find https://doc.qt.io/qt-5/qvboxlayout.html and there it is clearly stated that it is in widgets module (qmake: QT += widgets).

                    https://forum.qt.io/topic/113070/qt-code-of-conduct

                    M 2 Replies Last reply
                    1
                    • jsulmJ jsulm

                      @Mitko said in PyQT4 App:

                      QVBoxLayout

                      Please do also some research on your own!
                      If you google for QVBoxLayout you will find https://doc.qt.io/qt-5/qvboxlayout.html and there it is clearly stated that it is in widgets module (qmake: QT += widgets).

                      M Offline
                      M Offline
                      Mitko
                      wrote on last edited by
                      #23

                      @jsulm
                      I'm new and don't understand everything

                      1 Reply Last reply
                      0
                      • jsulmJ jsulm

                        @Mitko said in PyQT4 App:

                        QVBoxLayout

                        Please do also some research on your own!
                        If you google for QVBoxLayout you will find https://doc.qt.io/qt-5/qvboxlayout.html and there it is clearly stated that it is in widgets module (qmake: QT += widgets).

                        M Offline
                        M Offline
                        Mitko
                        wrote on last edited by
                        #24

                        @jsulm

                        I've try this but i have same error

                        from PyQt5.QtWidgets import (QApplication, QWidget, QVBoxLayout, QHBoxLayout,
                                                     QPushButton, QLabel, QLineEdit, QTabBar,
                                                     QFrame, QStackedLayout)
                        
                        JonBJ 1 Reply Last reply
                        0
                        • M Mitko

                          @jsulm

                          I've try this but i have same error

                          from PyQt5.QtWidgets import (QApplication, QWidget, QVBoxLayout, QHBoxLayout,
                                                       QPushButton, QLabel, QLineEdit, QTabBar,
                                                       QFrame, QStackedLayout)
                          
                          JonBJ Offline
                          JonBJ Offline
                          JonB
                          wrote on last edited by
                          #25

                          @Mitko
                          You should only get the same error if you left the code with QtGui.QVBoxLayout(self.centralWidget). After the import it should work with plain QVBoxLayout(self.centralWidget). Otherwise please don't say " same error" when so many errors are flying around, please show the actual line of any error and paste the error message.

                          M 1 Reply Last reply
                          1
                          • JonBJ JonB

                            @Mitko
                            You should only get the same error if you left the code with QtGui.QVBoxLayout(self.centralWidget). After the import it should work with plain QVBoxLayout(self.centralWidget). Otherwise please don't say " same error" when so many errors are flying around, please show the actual line of any error and paste the error message.

                            M Offline
                            M Offline
                            Mitko
                            wrote on last edited by
                            #26

                            @JonB

                            When i use:

                            from PyQt5 import QtWidgets, QtCore, QtGui, QVBoxLayout
                            

                            I have this:

                            File "C:/xbee-gui-master/MainForm.py", line 3, in <module>
                             from PyQt5 import QtWidgets, QtCore, QtGui, QVBoxLayout
                            ImportError: cannot import name 'QVBoxLayout' from 'PyQt5' (C:\xbee-gui-master\PyQT\lib\site-packages\PyQt5\__init__.py)
                            

                            When i use:

                            from PyQt5 import QtWidgets, QtCore, QtGui
                            
                            from PyQt5.QtWidgets import (QApplication, QWidget, QVBoxLayout, QHBoxLayout,
                                                         QPushButton, QLabel, QLineEdit, QTabBar,
                                                         QFrame, QStackedLayout)
                            

                            I have this:

                            File "C:/xbee-gui-master/MainForm.py", line 35, in __init__
                               self.centralWidgetLayout = QtGui.QVBoxLayout(self.centralWidget)
                            AttributeError: module 'PyQt5.QtGui' has no attribute 'QVBoxLayout'
                            
                            JonBJ 1 Reply Last reply
                            0
                            • M Mitko

                              @JonB

                              When i use:

                              from PyQt5 import QtWidgets, QtCore, QtGui, QVBoxLayout
                              

                              I have this:

                              File "C:/xbee-gui-master/MainForm.py", line 3, in <module>
                               from PyQt5 import QtWidgets, QtCore, QtGui, QVBoxLayout
                              ImportError: cannot import name 'QVBoxLayout' from 'PyQt5' (C:\xbee-gui-master\PyQT\lib\site-packages\PyQt5\__init__.py)
                              

                              When i use:

                              from PyQt5 import QtWidgets, QtCore, QtGui
                              
                              from PyQt5.QtWidgets import (QApplication, QWidget, QVBoxLayout, QHBoxLayout,
                                                           QPushButton, QLabel, QLineEdit, QTabBar,
                                                           QFrame, QStackedLayout)
                              

                              I have this:

                              File "C:/xbee-gui-master/MainForm.py", line 35, in __init__
                                 self.centralWidgetLayout = QtGui.QVBoxLayout(self.centralWidget)
                              AttributeError: module 'PyQt5.QtGui' has no attribute 'QVBoxLayout'
                              
                              JonBJ Offline
                              JonBJ Offline
                              JonB
                              wrote on last edited by JonB
                              #27

                              @Mitko
                              The first error is correct. from PyQt5 import QtWidgets, QtCore, QtGui is good. QVBoxLayout is not in PyQt5, so the error is correct.

                              Your second example is correct. QtWidgets does contain QVBoxLayout so that is good.

                              Given which, it is hardly surprising that

                              self.centralWidgetLayout = QtGui.QVBoxLayout(self.centralWidget)
                              

                              gives the error it does, is it? You know that QVBoxLayout has been moved from QtGui in Qt 4 to QtWidgets in Qt 5, don't you, because that is what you are supposed to be changing to make it work. So there's no point putting what used to work and does not work now.

                              Given your second example code, there are two ways you can address QVBoxLayout:

                              • QtWidgets.QVBoxLayout: This is allowed from your from PyQt5 import QtWidgets line.

                              • QVBoxLayout: This is allowed from your from PyQt5.QtWidgets import (QApplication, QWidget, QVBoxLayout, ... line.

                              M 1 Reply Last reply
                              1
                              • JonBJ JonB

                                @Mitko
                                The first error is correct. from PyQt5 import QtWidgets, QtCore, QtGui is good. QVBoxLayout is not in PyQt5, so the error is correct.

                                Your second example is correct. QtWidgets does contain QVBoxLayout so that is good.

                                Given which, it is hardly surprising that

                                self.centralWidgetLayout = QtGui.QVBoxLayout(self.centralWidget)
                                

                                gives the error it does, is it? You know that QVBoxLayout has been moved from QtGui in Qt 4 to QtWidgets in Qt 5, don't you, because that is what you are supposed to be changing to make it work. So there's no point putting what used to work and does not work now.

                                Given your second example code, there are two ways you can address QVBoxLayout:

                                • QtWidgets.QVBoxLayout: This is allowed from your from PyQt5 import QtWidgets line.

                                • QVBoxLayout: This is allowed from your from PyQt5.QtWidgets import (QApplication, QWidget, QVBoxLayout, ... line.

                                M Offline
                                M Offline
                                Mitko
                                wrote on last edited by
                                #28

                                @JonB

                                Hi, i'm really grateful for your help so far.

                                I managed to clear that types of errors.

                                But now i have different types of error:

                                 C:\xbee-gui-master\PyQT\Scripts\python.exe C:/xbee-gui-master/MainForm.py
                                Traceback (most recent call last):
                                  File "C:/xbee-gui-master/MainForm.py", line 367, in <module>
                                    main()
                                  File "C:/xbee-gui-master/MainForm.py", line 362, in main
                                    bl = Block()
                                  File "C:/xbee-gui-master/MainForm.py", line 50, in __init__
                                    self.all_tab()
                                  File "C:/xbee-gui-master/MainForm.py", line 63, in all_tab
                                    self.tab_control()
                                  File "C:/xbee-gui-master/MainForm.py", line 160, in tab_control
                                    self.list_all_commands()
                                  File "C:/xbee-gui-master/MainForm.py", line 211, in list_all_commands
                                    self.connect(self.view, QtCore.SIGNAL("clicked(const QModelIndex&)"), on_item_clicked)
                                AttributeError: 'Block' object has no attribute 'connect' 
                                

                                Can you please help me ?

                                JonBJ 1 Reply Last reply
                                0
                                • SGaistS Offline
                                  SGaistS Offline
                                  SGaist
                                  Lifetime Qt Champion
                                  wrote on last edited by
                                  #29

                                  You wrote as if it was C++. That's wrong.

                                  With PyQt/PySide:

                                  source_object.name_of_signal.connect(target_object.name_of_slot)
                                  

                                  Replace source_object and target_object with suitable objects in your code.

                                  Note that in the project your linked to, there are several connect statements already done.

                                  Interested in AI ? www.idiap.ch
                                  Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                                  1 Reply Last reply
                                  1
                                  • M Mitko

                                    @JonB

                                    Hi, i'm really grateful for your help so far.

                                    I managed to clear that types of errors.

                                    But now i have different types of error:

                                     C:\xbee-gui-master\PyQT\Scripts\python.exe C:/xbee-gui-master/MainForm.py
                                    Traceback (most recent call last):
                                      File "C:/xbee-gui-master/MainForm.py", line 367, in <module>
                                        main()
                                      File "C:/xbee-gui-master/MainForm.py", line 362, in main
                                        bl = Block()
                                      File "C:/xbee-gui-master/MainForm.py", line 50, in __init__
                                        self.all_tab()
                                      File "C:/xbee-gui-master/MainForm.py", line 63, in all_tab
                                        self.tab_control()
                                      File "C:/xbee-gui-master/MainForm.py", line 160, in tab_control
                                        self.list_all_commands()
                                      File "C:/xbee-gui-master/MainForm.py", line 211, in list_all_commands
                                        self.connect(self.view, QtCore.SIGNAL("clicked(const QModelIndex&)"), on_item_clicked)
                                    AttributeError: 'Block' object has no attribute 'connect' 
                                    

                                    Can you please help me ?

                                    JonBJ Offline
                                    JonBJ Offline
                                    JonB
                                    wrote on last edited by
                                    #30

                                    @Mitko

                                    self.connect(self.view, QtCore.SIGNAL("clicked(const QModelIndex&)"), on_item_clicked)
                                    

                                    That is the original.

                                    • I have never heard of self.connect().

                                    • I doubt that QtCore.SIGNAL("clicked(const QModelIndex&)") is acceptable, but I don't know.

                                    I would try

                                    self.view.clicked.connect(on_item_clicked)
                                    

                                    Meanwhile separately I note that the code has:

                                    class Block(QtGui.QMainWindow, QtGui.QTreeView):
                                    

                                    That means Block is derived from two QObjects, QMainWindow & QTreeView. This is explicitly forbidden in Qt, at least in Qt5 and/or C++. Maybe it worked in Qt4/PyQt4, but will not now in any circumstances....

                                    Meanwhile, I don't know why you couldn't find this for yourself but isn't https://github.com/RuslanSdk/XBee-PyQt5-V.1.0 like it says Qt5/PyQt5 and what you want?

                                    M 1 Reply Last reply
                                    1
                                    • JonBJ JonB

                                      @Mitko

                                      self.connect(self.view, QtCore.SIGNAL("clicked(const QModelIndex&)"), on_item_clicked)
                                      

                                      That is the original.

                                      • I have never heard of self.connect().

                                      • I doubt that QtCore.SIGNAL("clicked(const QModelIndex&)") is acceptable, but I don't know.

                                      I would try

                                      self.view.clicked.connect(on_item_clicked)
                                      

                                      Meanwhile separately I note that the code has:

                                      class Block(QtGui.QMainWindow, QtGui.QTreeView):
                                      

                                      That means Block is derived from two QObjects, QMainWindow & QTreeView. This is explicitly forbidden in Qt, at least in Qt5 and/or C++. Maybe it worked in Qt4/PyQt4, but will not now in any circumstances....

                                      Meanwhile, I don't know why you couldn't find this for yourself but isn't https://github.com/RuslanSdk/XBee-PyQt5-V.1.0 like it says Qt5/PyQt5 and what you want?

                                      M Offline
                                      M Offline
                                      Mitko
                                      wrote on last edited by
                                      #31

                                      @JonB

                                      I think i fix this:

                                      self.view.clicked.connect(on_item_clicked)
                                      

                                      About the "Block" error - is there some Qt5 replacement ?

                                      About the project you refer to - i've tried it and it can be runned, but it can't load more then one xbee modules, and i wish to establish a network with meny devices.
                                      I tried to contact the creator, but he don't reply.

                                      Meanwhile i have new errors:

                                       C:\xbee-gui-master\PyQT\Scripts\python.exe C:/xbee-gui-master/MainForm.py
                                      Traceback (most recent call last):
                                        File "C:/xbee-gui-master/MainForm.py", line 367, in <module>
                                          main()
                                        File "C:/xbee-gui-master/MainForm.py", line 362, in main
                                          bl = Block()
                                        File "C:/xbee-gui-master/MainForm.py", line 50, in __init__
                                          self.all_tab()
                                        File "C:/xbee-gui-master/MainForm.py", line 63, in all_tab
                                          self.tab_control()
                                        File "C:/xbee-gui-master/MainForm.py", line 174, in tab_control
                                          model = QtWidgets.QStringListModel()
                                      AttributeError: module 'PyQt5.QtWidgets' has no attribute 'QStringListModel'
                                      

                                      Any help, please ?

                                      JonBJ 1 Reply Last reply
                                      0
                                      • M Mitko

                                        @JonB

                                        I think i fix this:

                                        self.view.clicked.connect(on_item_clicked)
                                        

                                        About the "Block" error - is there some Qt5 replacement ?

                                        About the project you refer to - i've tried it and it can be runned, but it can't load more then one xbee modules, and i wish to establish a network with meny devices.
                                        I tried to contact the creator, but he don't reply.

                                        Meanwhile i have new errors:

                                         C:\xbee-gui-master\PyQT\Scripts\python.exe C:/xbee-gui-master/MainForm.py
                                        Traceback (most recent call last):
                                          File "C:/xbee-gui-master/MainForm.py", line 367, in <module>
                                            main()
                                          File "C:/xbee-gui-master/MainForm.py", line 362, in main
                                            bl = Block()
                                          File "C:/xbee-gui-master/MainForm.py", line 50, in __init__
                                            self.all_tab()
                                          File "C:/xbee-gui-master/MainForm.py", line 63, in all_tab
                                            self.tab_control()
                                          File "C:/xbee-gui-master/MainForm.py", line 174, in tab_control
                                            model = QtWidgets.QStringListModel()
                                        AttributeError: module 'PyQt5.QtWidgets' has no attribute 'QStringListModel'
                                        

                                        Any help, please ?

                                        JonBJ Offline
                                        JonBJ Offline
                                        JonB
                                        wrote on last edited by JonB
                                        #32

                                        @Mitko
                                        Now it's time for you to do the looking up. These questions are the same each time, and I don't see why I should look up the documentation for you.

                                        The error tells you why you can't write QtWidgets.QStringListModel(). So you need to find whatever module QStringListModel() is in.

                                        M 2 Replies Last reply
                                        2
                                        • JonBJ JonB

                                          @Mitko
                                          Now it's time for you to do the looking up. These questions are the same each time, and I don't see why I should look up the documentation for you.

                                          The error tells you why you can't write QtWidgets.QStringListModel(). So you need to find whatever module QStringListModel() is in.

                                          M Offline
                                          M Offline
                                          Mitko
                                          wrote on last edited by
                                          #33

                                          @JonB
                                          Since you saw that i'm now to this, can't you just say:

                                          ''QStringListModel is a QtCore class, not QtWidgets'' ?

                                          JonBJ jsulmJ 2 Replies Last reply
                                          0

                                          • Login

                                          • Login or register to search.
                                          • First post
                                            Last post
                                          0
                                          • Categories
                                          • Recent
                                          • Tags
                                          • Popular
                                          • Users
                                          • Groups
                                          • Search
                                          • Get Qt Extensions
                                          • Unsolved