c++ - Qt: get text from button in QTableWidget -
QTableWidget in my Qt application, and I add it to the button like this:
QPushButton * startButton = new QPushButton ("Start"); Ui- & gt; Table Widget_tvConnection-> Set Grade (line, call, start button); Connect (Startbutton, Signal (clicked)), This slot (Startbutton pressed ()); And when it is pressed, I need to get the text from it, so I tried to do it:
void MainWindow: : StartButtonPressed () {... QPushButton * button = ui- & gt; Table Widget_tvConnection-> Salviddetate (row, color); QDebug () & lt; & Lt; Button & gt; Text (); } but the compiler does not allow me to convert from QWidget * to QPushButton *:
Error: From 'QWidget *' to 'QPushButton' Invalid conversion * '[-fpermissive] Is it possible to receive text from buttons within QTableWidget? If this is not mine, then how to solve it in my application, but it would be really good.
You get QWidget , so you get it from QPushButton . After this, you will be able to use it as a normal pushbutton . Try it out: QPushButton * button = qobject_cast & lt; QPushButton * & gt; (Ui- & gt; Table_View_tvConnection-> Selviddetate (row, color)); If (button) {// success} and {// bad}
Comments
Post a Comment