How to acces ui elements from another page?
-
I have a this code for get avaiable serial ports on Main Window.
QString parsedPortName = QSerialPortInfo::availablePorts().at(ui -> comboBoxDevices -> currentIndex()).portName();I need access this avaiable ports from another Page. Hiw can I do that?
Here, on my Second Window I need replace avaiable comports with
(QString("COM3")if (serialStartStop.begin(QString("COM3"), 9600, 8, 0, 1, 0, false) ) { serialStartStop.send("B" + ui->baslatmaedit->text().toLatin1() + "D"+ ui->durdurmaedit->text().toLatin1()); } -
I have a this code for get avaiable serial ports on Main Window.
QString parsedPortName = QSerialPortInfo::availablePorts().at(ui -> comboBoxDevices -> currentIndex()).portName();I need access this avaiable ports from another Page. Hiw can I do that?
Here, on my Second Window I need replace avaiable comports with
(QString("COM3")if (serialStartStop.begin(QString("COM3"), 9600, 8, 0, 1, 0, false) ) { serialStartStop.send("B" + ui->baslatmaedit->text().toLatin1() + "D"+ ui->durdurmaedit->text().toLatin1()); }@mangekoyu said in How to acces ui elements from another page?:
QSerialPortInfo::availablePorts()
availablePorts is a static method, so simply do it in the same way you are doing in MainWindow.
Or what is the problem? -
@jsulm said in How to acces ui elements from another page?:
I don't want select comport again on second wondow. Just I want get selected port on second window.
@mangekoyu
It is not a good design decision to have other windows know about/call things in a main window you have. It makes them dependent on there being a main window, and accessing it.If the main window creates the other window/page why not have it call a public method in that window/page to tell it which port has been selected? Or emit a signal when the choice changes to which it has attached a slot in the other page/window which wants to know?
-
@JonB said in How to acces ui elements from another page?:
a pencere diğer pencereyi/sayfayı oluşturuyorsa, neden o pencerede/sayfada hangi bağlantı noktası
So, How can I get avaiable serial ports? I just need get avaiabvle serial ports.
@mangekoyu
You already know that:QSerialPortInfo::availablePorts().Call that where you want them, or have main window call it and pass the result to some other window/page if that is how you want to do it.