How to add list of dictionary key data items into QTableWidget using pyqt4
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ height:90px;width:728px;box-sizing:border-box;
}
Here is my code,i want to add my list of items into qtabl widget in one key i have a list of items when i want to add my list of items in to qtable widget i am getting the problem i.e my last items is overriding the previous item because of the idx index in columns.i tried many ways but i not able to all the items in qtable widget.
Given below is my sample tried code:
from PyQt4 import QtCore, QtGui
from functools import partial
import os, sys
import time
from datetime import datetime
class MainWindow(QtGui.QMainWindow):
def __init__(self, parent=None):
self.data_arraylist = {'85207':[{'item1':"Fruites", 'Qty':'10','Price':'100','total':'100'},{'item1':"Banana", 'Qty':'20','Price':'200','total':'200'}],'97895':{'item1':"vegitables", 'Qty':'2kg','Price':'200','total':'200'},'97055':{'item1':"snacks", 'Qty':'10p','Price':'200','total':'200'}}
super(MainWindow, self).__init__(parent)
self.dataw = QtGui.QWidget()
self._gridlayout = QtGui.QGridLayout()
self.vboxdata = QtGui.QVBoxLayout(self.dataw)
self.scrollArea = QtGui.QScrollArea()
self.vboxdata.addWidget(self.scrollArea)
self.scrollArea.setWidgetResizable(True)
self.vbox = QtGui.QVBoxLayout()
self.hbox1 = QtGui.QHBoxLayout()
self.timelabel = QtGui.QLabel()
self.orderbtn = QtGui.QPushButton("Orders")
self.newbtn = QtGui.QPushButton("New")
self.newbtn.clicked.connect(self.items_list)
self.hbox1.addWidget(self.timelabel)
self.hbox1.addWidget(self.orderbtn)
self.hbox1.addWidget(self.newbtn)
self.vbox.addLayout(self.hbox1)
self.mainLayout = QtGui.QGridLayout()
self.mainLayout.addWidget(self.dataw, 0, 0)
self.mainLayout.addLayout(self.vbox, 1, 0)
self.setCentralWidget(QtGui.QWidget(self))
self.centralWidget().setLayout(self.mainLayout)
def items_list(self):
self.mainw2 = QtGui.QWidget()
self.scrollArea.setWidget(self.mainw2)
self.newvbox = QtGui.QVBoxLayout(self.mainw2)
self.linedit = QtGui.QLineEdit()
self.search = QtGui.QLabel("Search")
self.newhbox = QtGui.QHBoxLayout()
self.newhbox.addWidget(self.linedit)
self.newhbox.addWidget(self.search)
self.newvbox.addLayout(self.newhbox)
self.table = QtGui.QTableWidget()
self.table_item = QtGui.QTableWidgetItem()
self.table.setRowCount(5)
self.table.verticalHeader().hide()
self.table.setColumnCount(5)
self.table.setEditTriggers(QtGui.QAbstractItemView.NoEditTriggers)
self.table.setHorizontalHeaderLabels(("S.no, Item Description,Qty,Rate(Rs:),Total").split(','))
self.newvbox.addWidget(self.table)
def keyPressEvent(self, event):
print event,event.key(),QtCore.Qt.Key_Return
if event.key() == QtCore.Qt.Key_Return:
text_key = self.linedit.text()
self.searchitems(text_key)
def searchitems(self,text_key):
if str(text_key) in self.data_arraylist:
for ridx,row in enumerate(range(1)):
for idx, column in enumerate(range(5)):
if idx ==0:
self.table.setItem(row,column,QtGui.QTableWidgetItem(str(ridx+1)))
elif idx ==1:
for i in range(len(self.data_arraylist[str(text_key)])):
self.table.setItem(row,column,QtGui.QTableWidgetItem(
str(self.data_arraylist[str(text_key)][i][
'item1'])))
elif idx ==2:
for i in range(len(self.data_arraylist[str(text_key)])):
self.table.setItem(row,column,
QtGui.QTableWidgetItem(str(
self.data_arraylist[str(
text_key)][i]['Qty'])))
elif idx ==3:
for i in range(len(self.data_arraylist[str(text_key)])):
self.table.setItem(row,column,QtGui.QTableWidgetItem(str(self.data_arraylist[str(text_key)][i]['Price'])))
elif idx ==4:
for i in range(len(self.data_arraylist[str(text_key)])):
self.table.setItem(row,column,QtGui.QTableWidgetItem(str(self.data_arraylist[str(text_key)][i]['total'])))
else:
pass
if __name__ == '__main__':
app = QtGui.QApplication(sys.argv)
w = MainWindow()
w.show()
w.setGeometry(500,500,800,400)
sys.exit(app.exec_())
python python-2.7 pyqt4
|
show 3 more comments
Here is my code,i want to add my list of items into qtabl widget in one key i have a list of items when i want to add my list of items in to qtable widget i am getting the problem i.e my last items is overriding the previous item because of the idx index in columns.i tried many ways but i not able to all the items in qtable widget.
Given below is my sample tried code:
from PyQt4 import QtCore, QtGui
from functools import partial
import os, sys
import time
from datetime import datetime
class MainWindow(QtGui.QMainWindow):
def __init__(self, parent=None):
self.data_arraylist = {'85207':[{'item1':"Fruites", 'Qty':'10','Price':'100','total':'100'},{'item1':"Banana", 'Qty':'20','Price':'200','total':'200'}],'97895':{'item1':"vegitables", 'Qty':'2kg','Price':'200','total':'200'},'97055':{'item1':"snacks", 'Qty':'10p','Price':'200','total':'200'}}
super(MainWindow, self).__init__(parent)
self.dataw = QtGui.QWidget()
self._gridlayout = QtGui.QGridLayout()
self.vboxdata = QtGui.QVBoxLayout(self.dataw)
self.scrollArea = QtGui.QScrollArea()
self.vboxdata.addWidget(self.scrollArea)
self.scrollArea.setWidgetResizable(True)
self.vbox = QtGui.QVBoxLayout()
self.hbox1 = QtGui.QHBoxLayout()
self.timelabel = QtGui.QLabel()
self.orderbtn = QtGui.QPushButton("Orders")
self.newbtn = QtGui.QPushButton("New")
self.newbtn.clicked.connect(self.items_list)
self.hbox1.addWidget(self.timelabel)
self.hbox1.addWidget(self.orderbtn)
self.hbox1.addWidget(self.newbtn)
self.vbox.addLayout(self.hbox1)
self.mainLayout = QtGui.QGridLayout()
self.mainLayout.addWidget(self.dataw, 0, 0)
self.mainLayout.addLayout(self.vbox, 1, 0)
self.setCentralWidget(QtGui.QWidget(self))
self.centralWidget().setLayout(self.mainLayout)
def items_list(self):
self.mainw2 = QtGui.QWidget()
self.scrollArea.setWidget(self.mainw2)
self.newvbox = QtGui.QVBoxLayout(self.mainw2)
self.linedit = QtGui.QLineEdit()
self.search = QtGui.QLabel("Search")
self.newhbox = QtGui.QHBoxLayout()
self.newhbox.addWidget(self.linedit)
self.newhbox.addWidget(self.search)
self.newvbox.addLayout(self.newhbox)
self.table = QtGui.QTableWidget()
self.table_item = QtGui.QTableWidgetItem()
self.table.setRowCount(5)
self.table.verticalHeader().hide()
self.table.setColumnCount(5)
self.table.setEditTriggers(QtGui.QAbstractItemView.NoEditTriggers)
self.table.setHorizontalHeaderLabels(("S.no, Item Description,Qty,Rate(Rs:),Total").split(','))
self.newvbox.addWidget(self.table)
def keyPressEvent(self, event):
print event,event.key(),QtCore.Qt.Key_Return
if event.key() == QtCore.Qt.Key_Return:
text_key = self.linedit.text()
self.searchitems(text_key)
def searchitems(self,text_key):
if str(text_key) in self.data_arraylist:
for ridx,row in enumerate(range(1)):
for idx, column in enumerate(range(5)):
if idx ==0:
self.table.setItem(row,column,QtGui.QTableWidgetItem(str(ridx+1)))
elif idx ==1:
for i in range(len(self.data_arraylist[str(text_key)])):
self.table.setItem(row,column,QtGui.QTableWidgetItem(
str(self.data_arraylist[str(text_key)][i][
'item1'])))
elif idx ==2:
for i in range(len(self.data_arraylist[str(text_key)])):
self.table.setItem(row,column,
QtGui.QTableWidgetItem(str(
self.data_arraylist[str(
text_key)][i]['Qty'])))
elif idx ==3:
for i in range(len(self.data_arraylist[str(text_key)])):
self.table.setItem(row,column,QtGui.QTableWidgetItem(str(self.data_arraylist[str(text_key)][i]['Price'])))
elif idx ==4:
for i in range(len(self.data_arraylist[str(text_key)])):
self.table.setItem(row,column,QtGui.QTableWidgetItem(str(self.data_arraylist[str(text_key)][i]['total'])))
else:
pass
if __name__ == '__main__':
app = QtGui.QApplication(sys.argv)
w = MainWindow()
w.show()
w.setGeometry(500,500,800,400)
sys.exit(app.exec_())
python python-2.7 pyqt4
2
Welcome to Stack Overflow! Can you elaborate on how your code "doesn't work"? What were you expecting, and what actually happened? If you got an exception/error, post the line it occurred on and the exception/error details. Please edit these details in or we may not be able to help. Add a Minimal, Complete, and Verifiable example that we can run and observe - your parial code is not executable. Do not post your whole code - simplyfy it as far as possible so nothing can be left out.
– Patrick Artner
Jan 4 at 12:50
sir I am beginner in pyqt4 i dont know why you are put my question in hold here i got the problem is when i assign the list of items in qtable widget last item is overriding the previous items in list ,so in my table i got the last item only here i print the row and column both item is tacking the same row and column position idx,i dont have much knowledge in this pyqt4 so please consider my question and help me out of this problem
– raghava
Jan 9 at 5:44
It does not matter whether you are a beginner or not, here we are interested in the question. He has not just put you on hold but we have been members of the community, since your original question indicates that something in your code does not work but the code you provided was not useful to understand where the problem is, so in that state it was impossible to help you because it was off-topic for the site, I recommend you read How to Ask, go through the tour again and review what we refer to with a Minimal, Complete, and Verifiable example
– eyllanesc
Jan 9 at 5:52
sir just now i edit the code i already mention my problem is here in dictionary i have a list of items here i got the only last item i.e [banana item] in my table i am not able to get the first of the list[fruites]how can i display the list of items in qtable widget .i know this syntax only to represent the items in table.please sir hel p me
– raghava
Jan 9 at 5:57
try looping over your input list and create an entry into your widget for every element in your dictionary: google it - f.e. reddit.com/r/learnpython/comments/3rtpv0/…
– Patrick Artner
Jan 9 at 6:47
|
show 3 more comments
Here is my code,i want to add my list of items into qtabl widget in one key i have a list of items when i want to add my list of items in to qtable widget i am getting the problem i.e my last items is overriding the previous item because of the idx index in columns.i tried many ways but i not able to all the items in qtable widget.
Given below is my sample tried code:
from PyQt4 import QtCore, QtGui
from functools import partial
import os, sys
import time
from datetime import datetime
class MainWindow(QtGui.QMainWindow):
def __init__(self, parent=None):
self.data_arraylist = {'85207':[{'item1':"Fruites", 'Qty':'10','Price':'100','total':'100'},{'item1':"Banana", 'Qty':'20','Price':'200','total':'200'}],'97895':{'item1':"vegitables", 'Qty':'2kg','Price':'200','total':'200'},'97055':{'item1':"snacks", 'Qty':'10p','Price':'200','total':'200'}}
super(MainWindow, self).__init__(parent)
self.dataw = QtGui.QWidget()
self._gridlayout = QtGui.QGridLayout()
self.vboxdata = QtGui.QVBoxLayout(self.dataw)
self.scrollArea = QtGui.QScrollArea()
self.vboxdata.addWidget(self.scrollArea)
self.scrollArea.setWidgetResizable(True)
self.vbox = QtGui.QVBoxLayout()
self.hbox1 = QtGui.QHBoxLayout()
self.timelabel = QtGui.QLabel()
self.orderbtn = QtGui.QPushButton("Orders")
self.newbtn = QtGui.QPushButton("New")
self.newbtn.clicked.connect(self.items_list)
self.hbox1.addWidget(self.timelabel)
self.hbox1.addWidget(self.orderbtn)
self.hbox1.addWidget(self.newbtn)
self.vbox.addLayout(self.hbox1)
self.mainLayout = QtGui.QGridLayout()
self.mainLayout.addWidget(self.dataw, 0, 0)
self.mainLayout.addLayout(self.vbox, 1, 0)
self.setCentralWidget(QtGui.QWidget(self))
self.centralWidget().setLayout(self.mainLayout)
def items_list(self):
self.mainw2 = QtGui.QWidget()
self.scrollArea.setWidget(self.mainw2)
self.newvbox = QtGui.QVBoxLayout(self.mainw2)
self.linedit = QtGui.QLineEdit()
self.search = QtGui.QLabel("Search")
self.newhbox = QtGui.QHBoxLayout()
self.newhbox.addWidget(self.linedit)
self.newhbox.addWidget(self.search)
self.newvbox.addLayout(self.newhbox)
self.table = QtGui.QTableWidget()
self.table_item = QtGui.QTableWidgetItem()
self.table.setRowCount(5)
self.table.verticalHeader().hide()
self.table.setColumnCount(5)
self.table.setEditTriggers(QtGui.QAbstractItemView.NoEditTriggers)
self.table.setHorizontalHeaderLabels(("S.no, Item Description,Qty,Rate(Rs:),Total").split(','))
self.newvbox.addWidget(self.table)
def keyPressEvent(self, event):
print event,event.key(),QtCore.Qt.Key_Return
if event.key() == QtCore.Qt.Key_Return:
text_key = self.linedit.text()
self.searchitems(text_key)
def searchitems(self,text_key):
if str(text_key) in self.data_arraylist:
for ridx,row in enumerate(range(1)):
for idx, column in enumerate(range(5)):
if idx ==0:
self.table.setItem(row,column,QtGui.QTableWidgetItem(str(ridx+1)))
elif idx ==1:
for i in range(len(self.data_arraylist[str(text_key)])):
self.table.setItem(row,column,QtGui.QTableWidgetItem(
str(self.data_arraylist[str(text_key)][i][
'item1'])))
elif idx ==2:
for i in range(len(self.data_arraylist[str(text_key)])):
self.table.setItem(row,column,
QtGui.QTableWidgetItem(str(
self.data_arraylist[str(
text_key)][i]['Qty'])))
elif idx ==3:
for i in range(len(self.data_arraylist[str(text_key)])):
self.table.setItem(row,column,QtGui.QTableWidgetItem(str(self.data_arraylist[str(text_key)][i]['Price'])))
elif idx ==4:
for i in range(len(self.data_arraylist[str(text_key)])):
self.table.setItem(row,column,QtGui.QTableWidgetItem(str(self.data_arraylist[str(text_key)][i]['total'])))
else:
pass
if __name__ == '__main__':
app = QtGui.QApplication(sys.argv)
w = MainWindow()
w.show()
w.setGeometry(500,500,800,400)
sys.exit(app.exec_())
python python-2.7 pyqt4
Here is my code,i want to add my list of items into qtabl widget in one key i have a list of items when i want to add my list of items in to qtable widget i am getting the problem i.e my last items is overriding the previous item because of the idx index in columns.i tried many ways but i not able to all the items in qtable widget.
Given below is my sample tried code:
from PyQt4 import QtCore, QtGui
from functools import partial
import os, sys
import time
from datetime import datetime
class MainWindow(QtGui.QMainWindow):
def __init__(self, parent=None):
self.data_arraylist = {'85207':[{'item1':"Fruites", 'Qty':'10','Price':'100','total':'100'},{'item1':"Banana", 'Qty':'20','Price':'200','total':'200'}],'97895':{'item1':"vegitables", 'Qty':'2kg','Price':'200','total':'200'},'97055':{'item1':"snacks", 'Qty':'10p','Price':'200','total':'200'}}
super(MainWindow, self).__init__(parent)
self.dataw = QtGui.QWidget()
self._gridlayout = QtGui.QGridLayout()
self.vboxdata = QtGui.QVBoxLayout(self.dataw)
self.scrollArea = QtGui.QScrollArea()
self.vboxdata.addWidget(self.scrollArea)
self.scrollArea.setWidgetResizable(True)
self.vbox = QtGui.QVBoxLayout()
self.hbox1 = QtGui.QHBoxLayout()
self.timelabel = QtGui.QLabel()
self.orderbtn = QtGui.QPushButton("Orders")
self.newbtn = QtGui.QPushButton("New")
self.newbtn.clicked.connect(self.items_list)
self.hbox1.addWidget(self.timelabel)
self.hbox1.addWidget(self.orderbtn)
self.hbox1.addWidget(self.newbtn)
self.vbox.addLayout(self.hbox1)
self.mainLayout = QtGui.QGridLayout()
self.mainLayout.addWidget(self.dataw, 0, 0)
self.mainLayout.addLayout(self.vbox, 1, 0)
self.setCentralWidget(QtGui.QWidget(self))
self.centralWidget().setLayout(self.mainLayout)
def items_list(self):
self.mainw2 = QtGui.QWidget()
self.scrollArea.setWidget(self.mainw2)
self.newvbox = QtGui.QVBoxLayout(self.mainw2)
self.linedit = QtGui.QLineEdit()
self.search = QtGui.QLabel("Search")
self.newhbox = QtGui.QHBoxLayout()
self.newhbox.addWidget(self.linedit)
self.newhbox.addWidget(self.search)
self.newvbox.addLayout(self.newhbox)
self.table = QtGui.QTableWidget()
self.table_item = QtGui.QTableWidgetItem()
self.table.setRowCount(5)
self.table.verticalHeader().hide()
self.table.setColumnCount(5)
self.table.setEditTriggers(QtGui.QAbstractItemView.NoEditTriggers)
self.table.setHorizontalHeaderLabels(("S.no, Item Description,Qty,Rate(Rs:),Total").split(','))
self.newvbox.addWidget(self.table)
def keyPressEvent(self, event):
print event,event.key(),QtCore.Qt.Key_Return
if event.key() == QtCore.Qt.Key_Return:
text_key = self.linedit.text()
self.searchitems(text_key)
def searchitems(self,text_key):
if str(text_key) in self.data_arraylist:
for ridx,row in enumerate(range(1)):
for idx, column in enumerate(range(5)):
if idx ==0:
self.table.setItem(row,column,QtGui.QTableWidgetItem(str(ridx+1)))
elif idx ==1:
for i in range(len(self.data_arraylist[str(text_key)])):
self.table.setItem(row,column,QtGui.QTableWidgetItem(
str(self.data_arraylist[str(text_key)][i][
'item1'])))
elif idx ==2:
for i in range(len(self.data_arraylist[str(text_key)])):
self.table.setItem(row,column,
QtGui.QTableWidgetItem(str(
self.data_arraylist[str(
text_key)][i]['Qty'])))
elif idx ==3:
for i in range(len(self.data_arraylist[str(text_key)])):
self.table.setItem(row,column,QtGui.QTableWidgetItem(str(self.data_arraylist[str(text_key)][i]['Price'])))
elif idx ==4:
for i in range(len(self.data_arraylist[str(text_key)])):
self.table.setItem(row,column,QtGui.QTableWidgetItem(str(self.data_arraylist[str(text_key)][i]['total'])))
else:
pass
if __name__ == '__main__':
app = QtGui.QApplication(sys.argv)
w = MainWindow()
w.show()
w.setGeometry(500,500,800,400)
sys.exit(app.exec_())
python python-2.7 pyqt4
python python-2.7 pyqt4
edited Jan 9 at 6:47
Patrick Artner
26.6k62544
26.6k62544
asked Jan 4 at 11:52
raghavaraghava
388
388
2
Welcome to Stack Overflow! Can you elaborate on how your code "doesn't work"? What were you expecting, and what actually happened? If you got an exception/error, post the line it occurred on and the exception/error details. Please edit these details in or we may not be able to help. Add a Minimal, Complete, and Verifiable example that we can run and observe - your parial code is not executable. Do not post your whole code - simplyfy it as far as possible so nothing can be left out.
– Patrick Artner
Jan 4 at 12:50
sir I am beginner in pyqt4 i dont know why you are put my question in hold here i got the problem is when i assign the list of items in qtable widget last item is overriding the previous items in list ,so in my table i got the last item only here i print the row and column both item is tacking the same row and column position idx,i dont have much knowledge in this pyqt4 so please consider my question and help me out of this problem
– raghava
Jan 9 at 5:44
It does not matter whether you are a beginner or not, here we are interested in the question. He has not just put you on hold but we have been members of the community, since your original question indicates that something in your code does not work but the code you provided was not useful to understand where the problem is, so in that state it was impossible to help you because it was off-topic for the site, I recommend you read How to Ask, go through the tour again and review what we refer to with a Minimal, Complete, and Verifiable example
– eyllanesc
Jan 9 at 5:52
sir just now i edit the code i already mention my problem is here in dictionary i have a list of items here i got the only last item i.e [banana item] in my table i am not able to get the first of the list[fruites]how can i display the list of items in qtable widget .i know this syntax only to represent the items in table.please sir hel p me
– raghava
Jan 9 at 5:57
try looping over your input list and create an entry into your widget for every element in your dictionary: google it - f.e. reddit.com/r/learnpython/comments/3rtpv0/…
– Patrick Artner
Jan 9 at 6:47
|
show 3 more comments
2
Welcome to Stack Overflow! Can you elaborate on how your code "doesn't work"? What were you expecting, and what actually happened? If you got an exception/error, post the line it occurred on and the exception/error details. Please edit these details in or we may not be able to help. Add a Minimal, Complete, and Verifiable example that we can run and observe - your parial code is not executable. Do not post your whole code - simplyfy it as far as possible so nothing can be left out.
– Patrick Artner
Jan 4 at 12:50
sir I am beginner in pyqt4 i dont know why you are put my question in hold here i got the problem is when i assign the list of items in qtable widget last item is overriding the previous items in list ,so in my table i got the last item only here i print the row and column both item is tacking the same row and column position idx,i dont have much knowledge in this pyqt4 so please consider my question and help me out of this problem
– raghava
Jan 9 at 5:44
It does not matter whether you are a beginner or not, here we are interested in the question. He has not just put you on hold but we have been members of the community, since your original question indicates that something in your code does not work but the code you provided was not useful to understand where the problem is, so in that state it was impossible to help you because it was off-topic for the site, I recommend you read How to Ask, go through the tour again and review what we refer to with a Minimal, Complete, and Verifiable example
– eyllanesc
Jan 9 at 5:52
sir just now i edit the code i already mention my problem is here in dictionary i have a list of items here i got the only last item i.e [banana item] in my table i am not able to get the first of the list[fruites]how can i display the list of items in qtable widget .i know this syntax only to represent the items in table.please sir hel p me
– raghava
Jan 9 at 5:57
try looping over your input list and create an entry into your widget for every element in your dictionary: google it - f.e. reddit.com/r/learnpython/comments/3rtpv0/…
– Patrick Artner
Jan 9 at 6:47
2
2
Welcome to Stack Overflow! Can you elaborate on how your code "doesn't work"? What were you expecting, and what actually happened? If you got an exception/error, post the line it occurred on and the exception/error details. Please edit these details in or we may not be able to help. Add a Minimal, Complete, and Verifiable example that we can run and observe - your parial code is not executable. Do not post your whole code - simplyfy it as far as possible so nothing can be left out.
– Patrick Artner
Jan 4 at 12:50
Welcome to Stack Overflow! Can you elaborate on how your code "doesn't work"? What were you expecting, and what actually happened? If you got an exception/error, post the line it occurred on and the exception/error details. Please edit these details in or we may not be able to help. Add a Minimal, Complete, and Verifiable example that we can run and observe - your parial code is not executable. Do not post your whole code - simplyfy it as far as possible so nothing can be left out.
– Patrick Artner
Jan 4 at 12:50
sir I am beginner in pyqt4 i dont know why you are put my question in hold here i got the problem is when i assign the list of items in qtable widget last item is overriding the previous items in list ,so in my table i got the last item only here i print the row and column both item is tacking the same row and column position idx,i dont have much knowledge in this pyqt4 so please consider my question and help me out of this problem
– raghava
Jan 9 at 5:44
sir I am beginner in pyqt4 i dont know why you are put my question in hold here i got the problem is when i assign the list of items in qtable widget last item is overriding the previous items in list ,so in my table i got the last item only here i print the row and column both item is tacking the same row and column position idx,i dont have much knowledge in this pyqt4 so please consider my question and help me out of this problem
– raghava
Jan 9 at 5:44
It does not matter whether you are a beginner or not, here we are interested in the question. He has not just put you on hold but we have been members of the community, since your original question indicates that something in your code does not work but the code you provided was not useful to understand where the problem is, so in that state it was impossible to help you because it was off-topic for the site, I recommend you read How to Ask, go through the tour again and review what we refer to with a Minimal, Complete, and Verifiable example
– eyllanesc
Jan 9 at 5:52
It does not matter whether you are a beginner or not, here we are interested in the question. He has not just put you on hold but we have been members of the community, since your original question indicates that something in your code does not work but the code you provided was not useful to understand where the problem is, so in that state it was impossible to help you because it was off-topic for the site, I recommend you read How to Ask, go through the tour again and review what we refer to with a Minimal, Complete, and Verifiable example
– eyllanesc
Jan 9 at 5:52
sir just now i edit the code i already mention my problem is here in dictionary i have a list of items here i got the only last item i.e [banana item] in my table i am not able to get the first of the list[fruites]how can i display the list of items in qtable widget .i know this syntax only to represent the items in table.please sir hel p me
– raghava
Jan 9 at 5:57
sir just now i edit the code i already mention my problem is here in dictionary i have a list of items here i got the only last item i.e [banana item] in my table i am not able to get the first of the list[fruites]how can i display the list of items in qtable widget .i know this syntax only to represent the items in table.please sir hel p me
– raghava
Jan 9 at 5:57
try looping over your input list and create an entry into your widget for every element in your dictionary: google it - f.e. reddit.com/r/learnpython/comments/3rtpv0/…
– Patrick Artner
Jan 9 at 6:47
try looping over your input list and create an entry into your widget for every element in your dictionary: google it - f.e. reddit.com/r/learnpython/comments/3rtpv0/…
– Patrick Artner
Jan 9 at 6:47
|
show 3 more comments
0
active
oldest
votes
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54038474%2fhow-to-add-list-of-dictionary-key-data-items-into-qtablewidget-using-pyqt4%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
0
active
oldest
votes
0
active
oldest
votes
active
oldest
votes
active
oldest
votes
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54038474%2fhow-to-add-list-of-dictionary-key-data-items-into-qtablewidget-using-pyqt4%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
2
Welcome to Stack Overflow! Can you elaborate on how your code "doesn't work"? What were you expecting, and what actually happened? If you got an exception/error, post the line it occurred on and the exception/error details. Please edit these details in or we may not be able to help. Add a Minimal, Complete, and Verifiable example that we can run and observe - your parial code is not executable. Do not post your whole code - simplyfy it as far as possible so nothing can be left out.
– Patrick Artner
Jan 4 at 12:50
sir I am beginner in pyqt4 i dont know why you are put my question in hold here i got the problem is when i assign the list of items in qtable widget last item is overriding the previous items in list ,so in my table i got the last item only here i print the row and column both item is tacking the same row and column position idx,i dont have much knowledge in this pyqt4 so please consider my question and help me out of this problem
– raghava
Jan 9 at 5:44
It does not matter whether you are a beginner or not, here we are interested in the question. He has not just put you on hold but we have been members of the community, since your original question indicates that something in your code does not work but the code you provided was not useful to understand where the problem is, so in that state it was impossible to help you because it was off-topic for the site, I recommend you read How to Ask, go through the tour again and review what we refer to with a Minimal, Complete, and Verifiable example
– eyllanesc
Jan 9 at 5:52
sir just now i edit the code i already mention my problem is here in dictionary i have a list of items here i got the only last item i.e [banana item] in my table i am not able to get the first of the list[fruites]how can i display the list of items in qtable widget .i know this syntax only to represent the items in table.please sir hel p me
– raghava
Jan 9 at 5:57
try looping over your input list and create an entry into your widget for every element in your dictionary: google it - f.e. reddit.com/r/learnpython/comments/3rtpv0/…
– Patrick Artner
Jan 9 at 6:47