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. Too frequent postEvent caused no responding
Forum Updated to NodeBB v4.3 + New Features

Too frequent postEvent caused no responding

Scheduled Pinned Locked Moved Unsolved General and Desktop
6 Posts 3 Posters 276 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.
  • L Offline
    L Offline
    lingyu 0
    wrote on last edited by
    #1

    Re: sendPostedEvents() or processEvents() causes SIGSEGV

    Hello sir, i have one similar problem.
    In my project, there is one GUI and a thread to receive data. Data will be posted to GUI about 10 times per second, and my GUI will draw a grid with new data and history data in one pixmap and show it. By my test, one pixmap will take about 40ms, so it will take about 400ms to draw pixmap per second. So I think there should not hava any problem.
    But in test, the GUI can't response to some mouse operations like resize and click. When I reduce the post frequency to 5/s, the GUI looked well. In addition, I also set the customevent priority less than Qt::LowEventPriority, no effect.

    jsulmJ 1 Reply Last reply
    0
    • L lingyu 0

      Re: sendPostedEvents() or processEvents() causes SIGSEGV

      Hello sir, i have one similar problem.
      In my project, there is one GUI and a thread to receive data. Data will be posted to GUI about 10 times per second, and my GUI will draw a grid with new data and history data in one pixmap and show it. By my test, one pixmap will take about 40ms, so it will take about 400ms to draw pixmap per second. So I think there should not hava any problem.
      But in test, the GUI can't response to some mouse operations like resize and click. When I reduce the post frequency to 5/s, the GUI looked well. In addition, I also set the customevent priority less than Qt::LowEventPriority, no effect.

      jsulmJ Offline
      jsulmJ Offline
      jsulm
      Lifetime Qt Champion
      wrote on last edited by
      #2

      @lingyu-0 Can you show your code where you're drawing?

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

      1 Reply Last reply
      0
      • L Offline
        L Offline
        lingyu 0
        wrote on last edited by
        #3

        sure!

        for (i = 0; i < nPageRow; i++)
            {
                QColor color = cellForeground(row, 0);
                if (isCellFlash(row, 0))
                {
                    if (nColorMode == E_Color_Dark)
                    {
                        color = color.dark();
                    }
                    else if (nColorMode == E_Color_Light)
                    {
                        color = color.light();
                    }
                }
        
                if (getColorMode())
                {
                    m_pPainter->fillRect(0, (i + 1)*m_nRowHeight, m_nClientWidth, m_nRowHeight, QBrush(color));
                    color = Qt::black;
                }
        
                if (isSelectRow(row))
                {
                    m_pPainter->fillRect(0, (i + 1)*m_nRowHeight, m_nClientWidth, m_nRowHeight, QBrush(m_SelectColor));
                }
                m_pPainter->setPen(color);
        
                if (m_bShowRowNo)
                    nColWidthSum = m_nNoRowWidth;
                else
                    nColWidthSum = 0;
                bool isFirst = true;
                col = m_nFirstPageCol;
                for (j = 0; j < m_nPageCols; j++)
                {
                    if (m_pColShow[col] == 0)
                    {
                        col++;
                        continue;
                    }
                    qstr = text(row, col);
                    nShowNum = 0;
                    if (!qstr.isNull() && !qstr.isEmpty())
                    {
                        nCharWidth = m_pPainterFM->width(qstr);
                        if (nCharWidth > 0)
                        {
                            nShowNum = (m_pColWidth[col] - 2 * g_nMarginWidth)*(qstr.length()) / nCharWidth;
                            nShowNum = nShowNum > (int)qstr.length() ? (int)qstr.length() : nShowNum;
                        }
                        qstr = qstr.left(nShowNum);
                        if (false)
                        {
                            m_pPainter->drawText(nColWidthSum + g_nMarginWidth + 10, (i + 1)*m_nRowHeight, m_pColWidth[col] - g_nMarginWidth, m_nRowHeight, Qt::AlignVCenter | Qt::AlignLeft, qstr);
                            QPixmap pixmap = QPixmap::fromImage(getRowIcon(row));
                            m_pPainter->drawPixmap(nColWidthSum, (i + 1)*m_nRowHeight + m_nRowHeight / 3, pixmap);
                            isFirst = false;
                        }
                        else
                        {
                            m_pPainter->drawText(nColWidthSum + g_nMarginWidth, (i + 1)*m_nRowHeight, m_pColWidth[col] - g_nMarginWidth, m_nRowHeight, Qt::AlignVCenter | Qt::AlignLeft, qstr);
                        }
                    }
                    nColWidthSum += m_pColWidth[col];
                    col++;
                }
                row++;
            }
        

        Text information is drawn here, and tables are drawn in other parts. I think drawText() takes the most time.

        jsulmJ 1 Reply Last reply
        0
        • L lingyu 0

          sure!

          for (i = 0; i < nPageRow; i++)
              {
                  QColor color = cellForeground(row, 0);
                  if (isCellFlash(row, 0))
                  {
                      if (nColorMode == E_Color_Dark)
                      {
                          color = color.dark();
                      }
                      else if (nColorMode == E_Color_Light)
                      {
                          color = color.light();
                      }
                  }
          
                  if (getColorMode())
                  {
                      m_pPainter->fillRect(0, (i + 1)*m_nRowHeight, m_nClientWidth, m_nRowHeight, QBrush(color));
                      color = Qt::black;
                  }
          
                  if (isSelectRow(row))
                  {
                      m_pPainter->fillRect(0, (i + 1)*m_nRowHeight, m_nClientWidth, m_nRowHeight, QBrush(m_SelectColor));
                  }
                  m_pPainter->setPen(color);
          
                  if (m_bShowRowNo)
                      nColWidthSum = m_nNoRowWidth;
                  else
                      nColWidthSum = 0;
                  bool isFirst = true;
                  col = m_nFirstPageCol;
                  for (j = 0; j < m_nPageCols; j++)
                  {
                      if (m_pColShow[col] == 0)
                      {
                          col++;
                          continue;
                      }
                      qstr = text(row, col);
                      nShowNum = 0;
                      if (!qstr.isNull() && !qstr.isEmpty())
                      {
                          nCharWidth = m_pPainterFM->width(qstr);
                          if (nCharWidth > 0)
                          {
                              nShowNum = (m_pColWidth[col] - 2 * g_nMarginWidth)*(qstr.length()) / nCharWidth;
                              nShowNum = nShowNum > (int)qstr.length() ? (int)qstr.length() : nShowNum;
                          }
                          qstr = qstr.left(nShowNum);
                          if (false)
                          {
                              m_pPainter->drawText(nColWidthSum + g_nMarginWidth + 10, (i + 1)*m_nRowHeight, m_pColWidth[col] - g_nMarginWidth, m_nRowHeight, Qt::AlignVCenter | Qt::AlignLeft, qstr);
                              QPixmap pixmap = QPixmap::fromImage(getRowIcon(row));
                              m_pPainter->drawPixmap(nColWidthSum, (i + 1)*m_nRowHeight + m_nRowHeight / 3, pixmap);
                              isFirst = false;
                          }
                          else
                          {
                              m_pPainter->drawText(nColWidthSum + g_nMarginWidth, (i + 1)*m_nRowHeight, m_pColWidth[col] - g_nMarginWidth, m_nRowHeight, Qt::AlignVCenter | Qt::AlignLeft, qstr);
                          }
                      }
                      nColWidthSum += m_pColWidth[col];
                      col++;
                  }
                  row++;
              }
          

          Text information is drawn here, and tables are drawn in other parts. I think drawText() takes the most time.

          jsulmJ Offline
          jsulmJ Offline
          jsulm
          Lifetime Qt Champion
          wrote on last edited by
          #4

          @lingyu-0 Maybe you should take a look at https://doc.qt.io/qt-5/qtcharts-index.html instead of doing it manually?

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

          L 1 Reply Last reply
          0
          • jsulmJ jsulm

            @lingyu-0 Maybe you should take a look at https://doc.qt.io/qt-5/qtcharts-index.html instead of doing it manually?

            L Offline
            L Offline
            lingyu 0
            wrote on last edited by
            #5

            @jsulm
            I didn't get the proper class in qtcharts. I need to show my data in a table like QTableWidget but it's more slowly.

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

              Hi,

              If it's table data... why not make a model with it and use a QTableView ?

              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
              0

              • Login

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