Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

How do I make connections between a text box, push button, and table



  • Ok so I am creating this application in QT designer and I want to fill in a text box then, confirm that information with a push button and that confirmed information to be populated into a table. I assumed that I use signals and slots but I am lost after that point.



  • @Jbrangiforte
    Yes you will use signals and slots. You should read https://doc.qt.io/qt-5/signalsandslots.html if you have not done so already.

    This situation is actually very simple. From your description, all you have to do is attach a slot to the pushbutton's click signal. There you look at what is in the text edit and copy it to wherever in your table.

    Designer allows you hook up signals to slots in a limited fashion. Most of us do not bother to use it, if you are tempted to do so, and write explicit connect()s in our code.

    Your "table" may actually be a model. Again, read https://doc.qt.io/qt-5/model-view-programming.html & https://doc.qt.io/qt-5/modelview.html. You might decide you want to use an editable model/view to directly edit items in the table. Depends on your usage.


  • Lifetime Qt Champion

    hehe JonB. waay faster than me :)

    To add to jonb. You could consider using a View with a QStringList as model.
    That way it's very easy to get the text from the text box into the table.

    But that is only if each list goes directly to one line in the table (Listbox type/ ONE col.)

    If you mean a real table with multiple cols then forget this.


Log in to reply