Important: Please read the Qt Code of Conduct -

How to convert String to Qpushbutton type

  • Hi all,

    I could like to pass all widget Id's to the code dynamically i.e. through .txt file so that i can make code as configurable,
    while read .txt file it reads in string data type but i need in Qpushboot type.

    So how to convert string data type to QpushButton data type in Qt.

    Thank you

  • Lifetime Qt Champion


    Do you mean like a Designer based UI ?

  • hi,
    Ya I have designed Ui file in designer and included in creator.

    my Ui have 100 buttons. and i want to set color and text on each button.
    so way to do the same is i have to write obj1.settext() and obj1.setcolor(),
    obj2.settext(),obj2.setcolor() on 100 times.

    but i want to make like x.settext(), x.setcolor()
    x will be configurable data. Reading from .txt file.

    but .txt read in string or char data type. how to convert string/char to Qpushbutton type.

    How can i make configurable design.

    Please suggest alternative way to achieve the same.

    Thank you

  • Lifetime Qt Champion

    Give an object name to all your buttons and then search them using this name to update their content from your file data.

  • HI SGaist,

    How can i get signal sender properties like id, state ..etc in slot?


    if signal generated on click on push button then it called some slot. Now how can get this button properties like Id of button, text on button..etc in slot..

  • Lifetime Qt Champion

    You can use e.g. sender()

    Why do you need all these information ?

  • Hi SGaist,
    Thank you for reply..
    I am making GUI application in which i have a requirements like 1. I have to handle events from Ui and 2. update processed on Ui.

    so i am making GUI module for my requirements with some conditions
    like Module should be configurable.
    so all events and its actions will be defined in config, code should excite the events as per configurations.

    for this i should know who is the sender of signals so that i can find sender/ event in config file and excite action as per config.

Log in to reply