[SOLVED] Is there a way to connect a QSlider and a QLineEdit object to each other?


I’m trying to connect a Slider and LineEdit widget together so that when one is changed the other will match this value.

I’m struggling since lineEdit takes strings and Slider takes ints. I already used setValidator on the lineEdit so that only ints can be entered.

I tried using the old signals and slots syntax with no luck using a couple different methods from a quick Google search.

connect(textbox, SIGNAL(textEdited(QString)),slider,

Should I be using a different widget entirely than LineEdit?


Use the lineEdit() method of QSpinBox():

connect(textbox, &QLineEdit::textEdited, slider->lineEdit(), &QLineEdit::setText);

Answered By – eyllanesc

Answer Checked By – Candace Johnson (BugsFixing Volunteer)

Leave a Reply

Your email address will not be published. Required fields are marked *