PDA

View Full Version : A qwidget passed to a function does nothing....



tonnot
1st March 2011, 19:39
This is a piece of code for my 'QTUTIL' class
.h

....
public
void time_start_crono(QWidget *indicador);
void time_update();
private:
QWidget *time_widget_indicator;
....
.cpp


void W_qtutil::time_start_crono(QWidget *indicador) {
time_widget_indicator=indicador;
....}
void W_qtutil::time_update() {
((QLabel) W_qtutil::time_widget_indicator).setText("hello");
}

I have at my mainwindow.cpp :

W_qtutil *w_qt=new W_qtutil();
w_qt->time_start_crono(ui->label_tiempo);
....
w_qt->time_update();

I create the w_qt using forward style (to avoid circular dependencies)
But My label are not updated ....
Any idea ? Thanks.

mcosta
1st March 2011, 21:01
Some questions:

1) time_update is not a slot;

2) To cast QObject use QObject::qobject_cast.

3 ) If you are sure that time_widget_indicator is a QLabel, why you don't declare it as QLabel?