0

I just need to know how can i link the value typed into the QLine, to a variable. I tried various methods like the returnPressed() but it didnt work. I already checked other questions, but i'd like to avoid the event filter. thanks

from PySide.QtGui import *
from PySide.QtCore import *

window = QWidget()
window.resize(500,300)
window.setWindowTitle('converter')

layout1 = QHBoxLayout()
layout2 = QVBoxLayout()

box = QComboBox()
box.addItems(['lenght','area','volume'])
box.setCurrentIndex(-1)
box.setObjectName('UNIT')
layout1.addWidget(box)


box2 = QComboBox()
box.setObjectName('FROM')
layout1.addWidget(box2)

line1 = QLineEdit()
line1.setObjectName('num1')
layout1.addWidget(line1)

box3 = QComboBox()
box3.setObjectName('TO')
layout1.addWidget(box3)

label = QLabel()
label.setObjectName('num2')

layout2.addLayout(layout1)
layout2.addWidget(label)
window.setLayout(layout2)

def changeValues():
    if box.currentIndex() == 0:
        box2.clear()
        box3.clear()
        box2.addItems(['km', 'km', 'cm', 'mm'])
        box3.addItems(['km', 'm', 'cm', 'mm'])
    elif box.currentIndex() == 1:
        box2.clear()
        box3.clear()
        box2.addItems(['km2', 'e', 'm2', 'cm2', 'mm2'])
        box3.addItems(['km2', 'e', 'm2', 'cm2', 'mm2'])
    elif box.currentIndex() == 2:
        box2.clear()
        box3.clear()
        box2.addItems(['m3', 'cm3', 'mm3', 'l', 'dl', 'cl', 'ml'])
        box3.addItems(['m3', 'cm3', 'mm3', 'l', 'dl', 'cl', 'ml'])


box.currentIndexChanged.connect(changeValues)

window.show()
  • What do you mean by "link the value ... to a variable"? And what does "didn't work" mean? – ekhumoro Nov 30 '14 at 20:11
  • i mean i'd like to have this situation: x = (value taken as input in the QLine) Then i want to elaborate the integer in x with a function. It's like when you do x = input('this line will be x') but in the QLine and i don't know how to do it – blackbird192 Dec 01 '14 at 01:21
  • Please show the code that you've got so far. – ekhumoro Dec 01 '14 at 01:24

0 Answers0