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. Displaying real-time data on a 2nd window
Forum Updated to NodeBB v4.3 + New Features

Displaying real-time data on a 2nd window

Scheduled Pinned Locked Moved Unsolved General and Desktop
51 Posts 4 Posters 9.5k Views 1 Watching
  • 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.
  • J john_hobbyist

    So the idea is that I have a window where I display a map of a country. Through a button I open another new window (auxiliary to the 1st window, I mean both windows exist after the opening of the 2nd window) where it should display some data. Everytime I move the mouse pointer (on the map) to different places, the second window should update the values and show new data, which does not happen. In order to check that the code works, I also print the data (that should be displayed and updated in real-time on the second window) on the terminal which work just fine! What I am missing here?

    In C++ I think this a volatile variable problem. But in python I have no idea! Is this a thread problem? Any ideas? (I work on PyQt5)

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

    @john_hobbyist
    It should be perfectly doable. You will have to show some code.

    But in python I have no idea! Is this a thread problem?

    Hopefully you are not using threads anyway? If you do, again show relevant code.

    1 Reply Last reply
    1
    • J Offline
      J Offline
      john_hobbyist
      wrote on last edited by john_hobbyist
      #3

      The 2nd window that displays the names of the towns (from where the pointer points on the 1st map) keeps only the 1st town I pointed. When I change position to the mouse pointer, it does not refresh the name on the 2nd window. I use a .csv file in order to pass data from the 1st window (class) to the 2nd window (class). Can you guide me? What should I check?

      JonBJ 1 Reply Last reply
      0
      • SGaistS Offline
        SGaistS Offline
        SGaist
        Lifetime Qt Champion
        wrote on last edited by
        #4

        Hi,

        Did you check that the signal arrives ?
        What are you using to show the information ?
        How do you do it ?

        Interested in AI ? www.idiap.ch
        Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

        J 1 Reply Last reply
        1
        • J john_hobbyist

          The 2nd window that displays the names of the towns (from where the pointer points on the 1st map) keeps only the 1st town I pointed. When I change position to the mouse pointer, it does not refresh the name on the 2nd window. I use a .csv file in order to pass data from the 1st window (class) to the 2nd window (class). Can you guide me? What should I check?

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

          @john_hobbyist said in Displaying real-time data on a 2nd window:

          I use a .csv file in order to pass data from the 1st window (class) to the 2nd window (class).

          Please first answer @SGaist's questions. But if you are using a file somehow to pass data between two windows rather than a signal that is likely not a good idea.

          1 Reply Last reply
          2
          • SGaistS SGaist

            Hi,

            Did you check that the signal arrives ?
            What are you using to show the information ?
            How do you do it ?

            J Offline
            J Offline
            john_hobbyist
            wrote on last edited by john_hobbyist
            #6

            @SGaist said in Displaying real-time data on a 2nd window:

            Hi,

            Did you check that the signal arrives ?
            What are you using to show the information ?
            How do you do it ?

            1. How I check them? With "print" commands do you mean?
            2. QLineEdit (on the 2nd window)
            3. I have a .csv with coordinates and the towns' name, when I change coordinates (by moving the mouse pointer) the name of the town on the 2nd window should change/refresh.

            What I see now, is that If I close the 2nd window and open a new one (2nd window again), the town's name is refreshed. But I cannot continuously refresh the 2nd window, the text inside the QLineEdit should be updated only... Do I miss something here?

            1 Reply Last reply
            0
            • SGaistS Offline
              SGaistS Offline
              SGaist
              Lifetime Qt Champion
              wrote on last edited by
              #7

              Yes, print is one option.

              Please show us the code you are using.

              Interested in AI ? www.idiap.ch
              Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

              1 Reply Last reply
              1
              • J Offline
                J Offline
                john_hobbyist
                wrote on last edited by
                #8

                From google search I found this: https://stackoverflow.com/questions/14630863/changing-text-in-qlineedit-of-qt-application-in-real-time and this: https://pythonpyqt.com/qtimer/

                So, how I attach Qtimer to a QLineEdit and update the text it has inside?

                JonBJ 1 Reply Last reply
                0
                • J john_hobbyist

                  From google search I found this: https://stackoverflow.com/questions/14630863/changing-text-in-qlineedit-of-qt-application-in-real-time and this: https://pythonpyqt.com/qtimer/

                  So, how I attach Qtimer to a QLineEdit and update the text it has inside?

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

                  @john_hobbyist said in Displaying real-time data on a 2nd window:

                  So, how I attach Qtimer to a QLineEdit and update the text it has inside?

                  Since both of your links, especially the first, show you, what is the question?

                  J 1 Reply Last reply
                  1
                  • JonBJ JonB

                    @john_hobbyist said in Displaying real-time data on a 2nd window:

                    So, how I attach Qtimer to a QLineEdit and update the text it has inside?

                    Since both of your links, especially the first, show you, what is the question?

                    J Offline
                    J Offline
                    john_hobbyist
                    wrote on last edited by
                    #10

                    @JonB said in Displaying real-time data on a 2nd window:

                    @john_hobbyist said in Displaying real-time data on a 2nd window:

                    So, how I attach Qtimer to a QLineEdit and update the text it has inside?

                    Since both of your links, especially the first, show you, what is the question?

                    It is in C++...

                    1 Reply Last reply
                    0
                    • SGaistS Offline
                      SGaistS Offline
                      SGaist
                      Lifetime Qt Champion
                      wrote on last edited by
                      #11

                      Indeed but that code is not really hard to translate to Python.

                      Interested in AI ? www.idiap.ch
                      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                      1 Reply Last reply
                      2
                      • J Offline
                        J Offline
                        john_hobbyist
                        wrote on last edited by john_hobbyist
                        #12
                            def __init__(self):
                                super().__init__()
                                import sys
                                from PyQt5.QtWidgets import QWidget,QPushButton,QApplication,QListWidget,QGridLayout,QLabel
                                from PyQt5.QtCore import QTimer,QDateTime
                                from PyQt5 import QtWidgets
                                from PyQt5.QtWidgets import QApplication, QMainWindow
                                from PyQt5 import QtCore
                                
                                timer = QtCore.QTimer()
                                timer.timeout.connect(self.ShowText)
                                timer.start(1000)
                                
                            def ShowText(self):
                                import pandas
                                win = QWidget()   
                                grid=QGridLayout()   
                                ct = pandas.read_csv('CurrentTown.csv')   
                                town = QLabel("town:")   
                                town.setStyleSheet("border: 1px solid black; background-color: yellow")   
                                grid.addWidget(town , 1,1)   
                                self.textEdit_1 = QLineEdit(ct)   
                                self.textEdit_1.setReadOnly(True)   
                                grid.addWidget(self.textEdit_1,1,2)   
                                       
                                import os
                                os.remove('CurrentTown.csv')   
                                self.setLayout(grid)   
                                win.setGeometry(100,100,200,100)   
                                win.setWindowTitle("Test")   
                                win.show()
                        

                        It does not display even a static text...and obviously it does not update anything on the textboxes, any ideas why?

                        1 Reply Last reply
                        0
                        • SGaistS Offline
                          SGaistS Offline
                          SGaist
                          Lifetime Qt Champion
                          wrote on last edited by
                          #13

                          That code does not define a widget nor anything within it so it's pretty hard to tell you what's wrong.

                          Interested in AI ? www.idiap.ch
                          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                          1 Reply Last reply
                          1
                          • J Offline
                            J Offline
                            john_hobbyist
                            wrote on last edited by john_hobbyist
                            #14

                            I updated it again...Any ideas???

                            1 Reply Last reply
                            0
                            • SGaistS Offline
                              SGaistS Offline
                              SGaist
                              Lifetime Qt Champion
                              wrote on last edited by
                              #15

                              Why are you recreating the whole widget each time ?
                              Why are you deleting the data file each time as well ?

                              Interested in AI ? www.idiap.ch
                              Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                              J 1 Reply Last reply
                              1
                              • SGaistS SGaist

                                Why are you recreating the whole widget each time ?
                                Why are you deleting the data file each time as well ?

                                J Offline
                                J Offline
                                john_hobbyist
                                wrote on last edited by john_hobbyist
                                #16

                                @SGaist I put

                                win = QWidget()   
                                grid=QGridLayout()
                                

                                inside

                                def __init__(self):
                                

                                again the same thing! One widget without any even a QLabel, QLineEdit, no data, nothing...

                                I use the .csv in order to pass and get value from another method from another class.

                                Any ideas?

                                1 Reply Last reply
                                0
                                • SGaistS Offline
                                  SGaistS Offline
                                  SGaist
                                  Lifetime Qt Champion
                                  wrote on last edited by
                                  #17

                                  Your code is incomplete so it's not possible to answer.
                                  However one thing is sure: creating and deleting a file to communicate between two classes in the same application is not the correct solution.

                                  If you want more help provide a minimal runnable script that shows what you are trying to do.

                                  Interested in AI ? www.idiap.ch
                                  Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                                  SGaistS 1 Reply Last reply
                                  1
                                  • J Offline
                                    J Offline
                                    john_hobbyist
                                    wrote on last edited by john_hobbyist
                                    #18

                                    How do I make this command:

                                    qle.textChanged[str].connect(self.onChanged)
                                    
                                    

                                    (source: https://zetcode.com/pyqt/qlineedit/)

                                    change the text in QLineEdit when "ct" variable has different value. "ct" variable is in my code...

                                    JonBJ 1 Reply Last reply
                                    0
                                    • SGaistS SGaist

                                      Your code is incomplete so it's not possible to answer.
                                      However one thing is sure: creating and deleting a file to communicate between two classes in the same application is not the correct solution.

                                      If you want more help provide a minimal runnable script that shows what you are trying to do.

                                      SGaistS Offline
                                      SGaistS Offline
                                      SGaist
                                      Lifetime Qt Champion
                                      wrote on last edited by
                                      #19

                                      @SGaist said in Displaying real-time data on a 2nd window:

                                      If you want more help provide a minimal runnable script that shows what you are trying to do.

                                      Interested in AI ? www.idiap.ch
                                      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                                      1 Reply Last reply
                                      1
                                      • J john_hobbyist

                                        How do I make this command:

                                        qle.textChanged[str].connect(self.onChanged)
                                        
                                        

                                        (source: https://zetcode.com/pyqt/qlineedit/)

                                        change the text in QLineEdit when "ct" variable has different value. "ct" variable is in my code...

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

                                        @john_hobbyist said in Displaying real-time data on a 2nd window:

                                        change the text in QLineEdit when "ct" variable has different value. "ct" variable is in my code...

                                        You ask about a piece of code which has no "ct variable" used in it. How do you think anybody can answer this?

                                        J 1 Reply Last reply
                                        1
                                        • JonBJ JonB

                                          @john_hobbyist said in Displaying real-time data on a 2nd window:

                                          change the text in QLineEdit when "ct" variable has different value. "ct" variable is in my code...

                                          You ask about a piece of code which has no "ct variable" used in it. How do you think anybody can answer this?

                                          J Offline
                                          J Offline
                                          john_hobbyist
                                          wrote on last edited by
                                          #21

                                          @JonB said in Displaying real-time data on a 2nd window:

                                          @john_hobbyist said in Displaying real-time data on a 2nd window:

                                          change the text in QLineEdit when "ct" variable has different value. "ct" variable is in my code...

                                          You ask about a piece of code which has no "ct variable" used in it. How do you think anybody can answer this?

                                          Please look at my code above. I have posted the code and where "ct" is used...

                                          JonBJ 1 Reply Last reply
                                          0

                                          • Login

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