Question

my problem looks like that. I got dialog window and i know how to get result from checked radiobutton but only in this window. How to take result into different window(mainwindow).

button(Pobierz) is on mainwindow and close to this button is lineedit2 where i would like to take result from checked radiobutton, but dont know how. I make lineedit in this new Dialog window and its taking result, but i dont know how to take this result into mainwindow. Hope I explain good enough. Thanks for any help.

void Pobierz::on_pushButton_clicked() 
{ 
if(ui->radioButton1->isChecked())
{
ui->lineEdit->setText("K");
}

if(ui->radioButton2->isChecked())  
{
ui->lineEdit->setText("S");
}    

if(ui->radioButton3->isChecked())    
{
ui->lineEdit->setText("I");
} 
}

Greetings,Tom. up1 i tried couple ways but still cant solve this..

Was it helpful?

Solution

In your class for the dialog, declare a signal that passes a QString. Also override the accept function (if you don't already). In the accept function, emit the signal with the appropriate string according to the radio buttons. (Don't forget to call the parent accept function in your own).

In your class for the main window, when you create the dialog, connect the signal from the dialog to a slot that sets the text in the line edit in the main window. When the dialog is accepted, the signal should fire, running the slot in the main dialog, adding the appropriate text to the line edit.

OTHER TIPS

Create a slot in the main window which would get the radio button status from the dialog window. In this slot set your main window's lineedit based on the result from the dialog window radio button checked status.

While creating the radio button on the dialog window, connect the radio button's clicked signal with the main window's slot defined earlier.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top