Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. How to acces ui elements from another page?

How to acces ui elements from another page?

Scheduled Pinned Locked Moved Unsolved General and Desktop
6 Posts 3 Posters 579 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • mangekoyuM Offline
    mangekoyuM Offline
    mangekoyu
    wrote on last edited by
    #1

    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());
    
           }
    
    jsulmJ 1 Reply Last reply
    0
    • mangekoyuM mangekoyu

      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());
      
             }
      
      jsulmJ Offline
      jsulmJ Offline
      jsulm
      Lifetime Qt Champion
      wrote on last edited by
      #2

      @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?

      https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • mangekoyuM Offline
        mangekoyuM Offline
        mangekoyu
        wrote on last edited by
        #3

        @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.

        JonBJ 1 Reply Last reply
        0
        • mangekoyuM mangekoyu

          @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.

          JonBJ Offline
          JonBJ Offline
          JonB
          wrote on last edited by JonB
          #4

          @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?

          1 Reply Last reply
          2
          • mangekoyuM Offline
            mangekoyuM Offline
            mangekoyu
            wrote on last edited by
            #5

            @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.

            JonBJ 1 Reply Last reply
            0
            • mangekoyuM mangekoyu

              @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.

              JonBJ Offline
              JonBJ Offline
              JonB
              wrote on last edited by JonB
              #6

              @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.

              1 Reply Last reply
              1

              • Login

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • Users
              • Groups
              • Search
              • Get Qt Extensions
              • Unsolved