Adding a label to the top/curent dialog
-
Hi All
I want to add a label to a current dialog on top of a frame. What I do to draw the label is the followinggame_layout.board.at( 0 ).level_data.at( 0 ).lable->move( 100, 100 ); game_layout.board.at( 0 ).level_data.at( 0 ).lable->show( );
however this opens a new widget for the label. How can I force it to draw the lable to the current dialog and the frame , eg ui->frame.
I've triedui->frame->game_layout.board.at( 0 ).level_data.at( 0 ).lable->move( 100, 100 ); ui->frame->game_layout.board.at( 0 ).level_data.at( 0 ).lable->show( );
but this as you'd expect gives an error. So I do I associate the label with the current dialog and the frame?
Thanks
-
should add I've seen addwidget eg ui->frame->addWidget however this function doesn't seem to exist? If I use ui->frame I'm only offered addaction(s)
-
@the_ said:
QLabel *myLabel = new QLabel(this);
ui->frame->layout()->addWidget(myLabel);Hi tried this and it just causes a seg fault?
@tony67 said:
Hi tried this and it just causes a seg fault?
Then your frame doesn't have a layout. Then
ui->frame->layout()
returnsNULL
, and voila you get a null dereferencing thus a segfault. Add a layout to your frame, and then add the widget(s) to it. This also have the nice side effect of you not calling,move
andshow
and any such things.