The documentation for the textEdited signal shows the use of a required parameter const QString&

void textEdited (const QString&)

I am unable to get the Signal to work. Perhaps because I do not understand how to use the "const QString&"

Is this a literal copy into the parameter or is it created from something else first?

I have a similar problem with

void itemActivated (QListWidgetItem *)

where it appears they are using a pointer to a QListWidgetItem

Coming from a VB6 background where C++ constructs do not exist.

I could really use some help with this.

Thanks!

That is not Python, it is C++. Before transferring to C++ forume, why do you have pyQT in title?

I think in C and C++ the & operator points to the string (array of characters). In Python that would simply be the string.

If you wanted to transfer from QLineEdit to a QLabel as you type you would use:

QtCore.QObject.connect(self.lineEdit, QtCore.SIGNAL(_fromUtf8("textEdited(QString)")), self.label.setText) 

Dang, is it ever tough to work wit the new code areas on DaniWeb!

Here is a simple example:

# explore PyQT QLineEdit and QLabel connection

from PyQt4.QtCore import *
from PyQt4.QtGui import *

class MyForm(QWidget):
    def __init__(self):
        QWidget.__init__(self)
        # setGeometry(x_pos, y_pos, width, height)
        self.setGeometry(100, 150, 300, 120)
        self.setWindowTitle("start typing")

        line_edit = QLineEdit(self)
        label = QLabel(self)
        # connect line_edit to label
        # update label each time the text has been edited
        line_edit.connect(line_edit, SIGNAL("textEdited(QString)"), label.setText)

        # use a grid layout for the widgets
        grid = QGridLayout()
        # addWidget(widget, row, column, rowSpan, columnSpan)
        grid.addWidget(line_edit, 0, 0, 1, 1)
        grid.addWidget(label, 1, 0, 1, 1)
        self.setLayout(grid)

app =  QApplication([])
form = MyForm()
form.show()
app.exec_()
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.