PyQT4 App
-
@jsulm
Thank you, i fix thisBut 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'
-
@jsulm
Thank you, i fix thisBut 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'
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). -
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). -
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). -
I've try this but i have same error
from PyQt5.QtWidgets import (QApplication, QWidget, QVBoxLayout, QHBoxLayout, QPushButton, QLabel, QLineEdit, QTabBar, QFrame, QStackedLayout)
@Mitko
You should only get the same error if you left the code withQtGui.QVBoxLayout(self.centralWidget)
. After theimport
it should work with plainQVBoxLayout(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. -
@Mitko
You should only get the same error if you left the code withQtGui.QVBoxLayout(self.centralWidget)
. After theimport
it should work with plainQVBoxLayout(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.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'
-
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'
@Mitko
The first error is correct.from PyQt5 import QtWidgets, QtCore, QtGui
is good.QVBoxLayout
is not inPyQt5
, so the error is correct.Your second example is correct.
QtWidgets
does containQVBoxLayout
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 fromQtGui
in Qt 4 toQtWidgets
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 yourfrom PyQt5 import QtWidgets
line. -
QVBoxLayout
: This is allowed from yourfrom PyQt5.QtWidgets import (QApplication, QWidget, QVBoxLayout, ...
line.
-
-
@Mitko
The first error is correct.from PyQt5 import QtWidgets, QtCore, QtGui
is good.QVBoxLayout
is not inPyQt5
, so the error is correct.Your second example is correct.
QtWidgets
does containQVBoxLayout
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 fromQtGui
in Qt 4 toQtWidgets
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 yourfrom PyQt5 import QtWidgets
line. -
QVBoxLayout
: This is allowed from yourfrom PyQt5.QtWidgets import (QApplication, QWidget, QVBoxLayout, ...
line.
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 ?
-
-
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.
-
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 ?
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 twoQObject
s,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?
-
-
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 twoQObject
s,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?
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 ?
-
-
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 ?
@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 moduleQStringListModel()
is in. -
@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 moduleQStringListModel()
is in. -
@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 moduleQStringListModel()
is in. -
@JonB
Since you saw that i'm now to this, can't you just say:''QStringListModel is a QtCore class, not QtWidgets'' ?
Since you saw that i'm now to this, can't you just say:
''QStringListModel is a QtCore class, not QtWidgets'' ?Since you saw how much help/time I've spent on this for you, given that I told you I am no Qt expert and it's just a question of you making the effort to actually just Google instead of me making that effort for your program, can't you just say:
"Thanks for all the help so far, you're quite right I can type that into Google, no reason why should do that for me"
?So your attitude is the more I help the more I should help, to save you effort, else I'm not doing the job I owe you? Find someone else.
-
Since you saw that i'm now to this, can't you just say:
''QStringListModel is a QtCore class, not QtWidgets'' ?Since you saw how much help/time I've spent on this for you, given that I told you I am no Qt expert and it's just a question of you making the effort to actually just Google instead of me making that effort for your program, can't you just say:
"Thanks for all the help so far, you're quite right I can type that into Google, no reason why should do that for me"
?So your attitude is the more I help the more I should help, to save you effort, else I'm not doing the job I owe you? Find someone else.
-
I already said:
''Hi, i'm really grateful for your help so far''.About the effort:
I don't have problems with efforts, i just don't understand the QT, and just needed little help for better understanding the details.And again- Thank you all !!!
@Mitko You do realize that in in the case of the "has no attribute XXX" error, several people explained to you that some classes have moved from one module to another and that the information can be found on the class documentation. Hence the only thing you have to do with that error is go to the class documentation to get the module you need to import that class from.
-
@Mitko You do realize that in in the case of the "has no attribute XXX" error, several people explained to you that some classes have moved from one module to another and that the information can be found on the class documentation. Hence the only thing you have to do with that error is go to the class documentation to get the module you need to import that class from.
-
@JonB
Since you saw that i'm now to this, can't you just say:''QStringListModel is a QtCore class, not QtWidgets'' ?
Since you saw that i'm now to this, can't you just say:
And can't you find it out by yourself?
You already asked these kind of questions and were told how to find this information.
Why should others do the research for you all the time?The fact that you are a beginner doesn't mean that you should not learn how to find needed information after you were told several times how to do so...