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. Main Window Not Redrawing Until Clicked
QtWS25 Last Chance

Main Window Not Redrawing Until Clicked

Scheduled Pinned Locked Moved Unsolved General and Desktop
qmainwindowrepaintupdate
4 Posts 2 Posters 275 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.
  • C Offline
    C Offline
    Calvin H-C
    wrote on 14 Nov 2024, 01:46 last edited by Calvin H-C
    #1

    I have an application that has a main window defined by Creator that has a QTableView used to show a list of objects' characteristics.

    The application receives data through a serial port that can update an object's characteristics, so I want the list to be update d when this happens. The problem I'm having is that the application's main window is not the focus when a change occurs and does not update when the information arrives. If I click on the application's window to give it focus, it will redraw at that moment.

    I have tried using both repaint() as well as update() for both the main window as well as the QTableView object, but all of these don't update the window until it is clicked on.

    This needs to update when the window is in the background or is the focus. I don't know what I'm missing.

    1 Reply Last reply
    0
    • C Offline
      C Offline
      Christian Ehrlicher
      Lifetime Qt Champion
      wrote on 14 Nov 2024, 05:11 last edited by
      #2

      Please provide some code - how do you update your model. Do you properly emit the needed signals?
      https://doc.qt.io/qt-6/model-view-programming.html#an-editable-model

      Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
      Visit the Qt Academy at https://academy.qt.io/catalog

      1 Reply Last reply
      0
      • C Offline
        C Offline
        Calvin H-C
        wrote on 14 Nov 2024, 06:00 last edited by Calvin H-C
        #3

        Yes, the signal is emitted with this:

        emit RequestRedraw();
        

        This is called when something has changed.

        The signal is connected to the slot when the main window is initialized:

        QObject::connect( pDoc, SIGNAL( RequestRedraw ), this, SLOT( update() ) );
        

        The QTableView (ElementView) is a child of the main window, so I tried changing the connect call to use it directly:

        QObject::connect( pDoc, SIGNAL( RequestRedraw ), ui->ElementView, SLOT( update() ) );
        

        This had the same effect: the update was not visible until the window was clicked on.

        The list model is NOT editable, as that would be impracticable since many of the fields displayed are status information (i.e. not something that can be edited by the user). This is also why it needs to be updated, whether the window is the focus or not.

        C 1 Reply Last reply 14 Nov 2024, 06:30
        0
        • C Calvin H-C
          14 Nov 2024, 06:00

          Yes, the signal is emitted with this:

          emit RequestRedraw();
          

          This is called when something has changed.

          The signal is connected to the slot when the main window is initialized:

          QObject::connect( pDoc, SIGNAL( RequestRedraw ), this, SLOT( update() ) );
          

          The QTableView (ElementView) is a child of the main window, so I tried changing the connect call to use it directly:

          QObject::connect( pDoc, SIGNAL( RequestRedraw ), ui->ElementView, SLOT( update() ) );
          

          This had the same effect: the update was not visible until the window was clicked on.

          The list model is NOT editable, as that would be impracticable since many of the fields displayed are status information (i.e. not something that can be edited by the user). This is also why it needs to be updated, whether the window is the focus or not.

          C Offline
          C Offline
          Christian Ehrlicher
          Lifetime Qt Champion
          wrote on 14 Nov 2024, 06:30 last edited by
          #4

          @Calvin-H-C said in Main Window Not Redrawing Until Clicked:

          Yes, the signal is emitted with this:

          This is not what the documentation tells you what has to be emitted when data in the model changes. Please read and follow the documentation. There are also enough examples out there.

          Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
          Visit the Qt Academy at https://academy.qt.io/catalog

          1 Reply Last reply
          2

          1/4

          14 Nov 2024, 01:46

          • Login

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