On Mon, 22 Mar 2004 08:30:18 +0100, "Leif B. Kristensen"
<ju******@solum slekt.org> wrote:
Can somebody point me to a quick example on how to display the result of
an SQL query in a PyQt QListBox? I've googled in vain for this.
Assuming you can get the results of your SQL query into string form,
it should be just a matter of inserting those strings into your
widget.
I don't know if this will help you, but here is a snip from one of my
classes where I am processing a list of text lines and displaying
those lines in a QTextEdit widget. The fields in each line are padded
to make everything come out in nice columns.
The snag that hung me up when I first started using PyQt was not
realizing that the "QStrings" that come out of a Qt widget (a C++
thingy) have to be converted to Python strings ( with the str function
). It's OK going the other way, however. You can insert a Python
string ( p below ) into a PyQt widget.
def slotParse(self) :
self.outputText Label.setText(s elf.simComboBox .currentText())
pystring = str(self.textEd it1.text()) # Convert QString to
pystring
modlist = pystring.splitl ines()
plist = parseMods(modli st)
for p in plist:
self.textEdit2. insert(p + '\n')
-- Dave