<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Duration of  aThread]]></title><description><![CDATA[<p dir="auto">Hello,<br />
I want know how I can get duration of a thread which I run in my program.<br />
Thanks for advance</p>
]]></description><link>https://forum.qt.io/topic/7189/duration-of-athread</link><generator>RSS for Node</generator><lastBuildDate>Sun, 12 Apr 2026 13:36:43 GMT</lastBuildDate><atom:link href="https://forum.qt.io/topic/7189.rss" rel="self" type="application/rss+xml"/><pubDate>Fri, 01 Jul 2011 07:42:20 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Duration of  aThread on Fri, 01 Jul 2011 09:45:25 GMT]]></title><description><![CDATA[<p dir="auto">In that case time is not interesting. You might want to emit a progressChanged() signal containing a percentage. Stick to what you know. You know exactly how many calculations you are going to do, but you have no real clue about how much time it will take to complete them. If you use a percentage output, you can use a standard QProgressDialog and use that. It will by default pop up after 4 seconds of operation, but you can change that value if you wish, or show() immediately.</p>
<p dir="auto">People are usually better at guessing or estimating (guestimating) the time to finish based on tasks-completed progress than computers are.</p>
]]></description><link>https://forum.qt.io/post/95580</link><guid isPermaLink="true">https://forum.qt.io/post/95580</guid><dc:creator><![CDATA[Franzk]]></dc:creator><pubDate>Fri, 01 Jul 2011 09:45:25 GMT</pubDate></item><item><title><![CDATA[Reply to Duration of  aThread on Fri, 01 Jul 2011 08:57:35 GMT]]></title><description><![CDATA[<p dir="auto">Here it is the Object which works..<br />
@<br />
class Worker :public QObject<br />
{</p>
<p dir="auto">public:<br />
void setModel( QAbstractItemModel *model)<br />
{<br />
m_model= model;<br />
}</p>
<pre><code>QAbstractItemModel *model()
{
    return m_model;
}
</code></pre>
<p dir="auto">private:<br />
QAbstractItemModel *m_model;</p>
<p dir="auto">signals:</p>
<p dir="auto">public slots:</p>
<pre><code>  void doWork()
  {

      //Extraction de la matrice
      int n=m_model-&gt;rowCount()-3;
      double  *mat=new double[n*n];
      double  *matInv=new double[n*n];

      for( int i=3,r=0; i &lt; m_model-&gt;rowCount(); ++i ,++r)
      {
          for(int j=3,c=0; j &lt; m_model-&gt;columnCount(); ++j,++c)
          {

              if(m_model-&gt;data(m_model-&gt;index(i,j)).isValid()){

                  mat[r+c*n]= m_model-&gt;data(m_model-&gt;index(i,j)).toDouble();
              }else
              {
                  mat[r+c*n]=0.;
              }

          }

      }


      //Inversion de la matrice
        InverseMatrix *inverser=new  InverseMatrix;
        inverser-&gt;gaussR(mat,matInv,n);

        //Retablissement de la matrice
        for( int i=3,r=0; i &lt;  m_model-&gt;rowCount(); ++i,++r )
        {

            for(int j=3,c=0; j &lt; m_model-&gt;columnCount(); ++j,++c)
            {

                if( m_model-&gt;data(m_model-&gt;index(i,j)).isValid() ){

                    if( matInv[r+c*n] !=0.0000)
                        m_model-&gt;setData(m_model-&gt;index(i,j),QString::number(matInv[r+c*n],'f',4));
                    else
                        m_model-&gt;setData(m_model-&gt;index(i,j),QString());
                        // m_model-&gt;,-&gt;setBackground(QBrush(QColor(255,241,113)));

                }else
                {
         
                    if( matInv[r+c*n] !=0.0000)
                        m_model-&gt;setData(m_model-&gt;index(i,j),QString::number(matInv[r+c*n],'f',4));
                    else
                         m_model-&gt;setData(m_model-&gt;index(i,j),QString());
                }

            }

        }

  }
</code></pre>
<p dir="auto">};</p>
<p dir="auto">@</p>
<p dir="auto">Now i call it from  an another Object cross  a thread<br />
@<br />
ScrollAreaInverseMatrix::ScrollAreaInverseMatrix(QWidget *parent) :<br />
QScrollArea(parent)<br />
{<br />
setupUi(this);<br />
setupContents();<br />
}</p>
<p dir="auto">void ScrollAreaInverseMatrix::setupContents()<br />
{</p>
<pre><code>  ScrollAreaMatriceIC *matrixIc=new ScrollAreaMatriceIC;

  if( matrixIc-&gt;getTableWidget() !=0){

      table=matrixIc-&gt;getTableWidget();

       QTableWidgetItem *curItem;
      for( int i=3 ;i &lt;  table-&gt;rowCount(); ++i)
      {

          for(int j=3; j &lt; table-&gt;columnCount(); ++j)
          {

              if( table-&gt;item(i,j) != 0){
                 table-&gt;item(i,j)-&gt;setBackground(QBrush(QColor(255,241,113)));

              }else
              {
                  curItem=new QTableWidgetItem;
                  curItem-&gt;setBackground(QBrush(QColor(255,241,113)));
                  table-&gt;setItem(i,j,curItem);
              }

          }
      }

      QTableView *view= new QTableView;
      horizontalLayout-&gt;addWidget(view);


      Worker * worker=new Worker;
      worker-&gt;setModel(table-&gt;model());
      worker-&gt;doWork();
      QThread *thread=new QThread;
      worker-&gt;moveToThread(thread);
      thread-&gt;start(QThread::HighestPriority);
      view-&gt;setModel(worker-&gt;model());

      QMessageBox dialog(QMessageBox::Information,"","Finished");
      connect(thread,SIGNAL(terminated()),&amp;dialog,SLOT(open()));
     //after my object is visible with results ,but dialog never shows..... 
  


        view-&gt;resizeColumnsToContents();
        view-&gt;resizeRowsToContents();

  }
</code></pre>
<p dir="auto">}<br />
@</p>
<p dir="auto">My aim is to show ProgressDialog which determines  elapsed time before my Object become visible with  my results(cause my object takes 4 seconds before it becomes visible).<br />
Thanks for advance.</p>
]]></description><link>https://forum.qt.io/post/95569</link><guid isPermaLink="true">https://forum.qt.io/post/95569</guid><dc:creator><![CDATA[maxoreli]]></dc:creator><pubDate>Fri, 01 Jul 2011 08:57:35 GMT</pubDate></item><item><title><![CDATA[Reply to Duration of  aThread on Fri, 01 Jul 2011 08:42:45 GMT]]></title><description><![CDATA[<p dir="auto">Do you want to measure the time or do you want to know when a thread terminates? It terminates when QThread::run() has completed. Please give more details about what you are trying to achieve if the existing posts do not answer your question.</p>
]]></description><link>https://forum.qt.io/post/95565</link><guid isPermaLink="true">https://forum.qt.io/post/95565</guid><dc:creator><![CDATA[dialingo]]></dc:creator><pubDate>Fri, 01 Jul 2011 08:42:45 GMT</pubDate></item><item><title><![CDATA[Reply to Duration of  aThread on Fri, 01 Jul 2011 08:24:04 GMT]]></title><description><![CDATA[<p dir="auto">it depends of thread implementation and required accuracy.<br />
The easiest qt-way is to create instance of QTime within thread and then use QTime::start() &amp; QTime::elapsed.</p>
]]></description><link>https://forum.qt.io/post/95561</link><guid isPermaLink="true">https://forum.qt.io/post/95561</guid><dc:creator><![CDATA[romankr]]></dc:creator><pubDate>Fri, 01 Jul 2011 08:24:04 GMT</pubDate></item><item><title><![CDATA[Reply to Duration of  aThread on Fri, 01 Jul 2011 07:55:54 GMT]]></title><description><![CDATA[<p dir="auto">If you want to know how long your thread runs, may be you can use a timer inconjunction with the signal finished(), started() and terminated() to measure.</p>
]]></description><link>https://forum.qt.io/post/95556</link><guid isPermaLink="true">https://forum.qt.io/post/95556</guid><dc:creator><![CDATA[rammi]]></dc:creator><pubDate>Fri, 01 Jul 2011 07:55:54 GMT</pubDate></item></channel></rss>