<?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[How can i extend the loops limit?]]></title><description><![CDATA[<p dir="auto">My Qt program crashes when it gets the loop 2500. How can I extend that limit?</p>
]]></description><link>https://forum.qt.io/topic/81702/how-can-i-extend-the-loops-limit</link><generator>RSS for Node</generator><lastBuildDate>Thu, 30 Apr 2026 18:39:27 GMT</lastBuildDate><atom:link href="https://forum.qt.io/topic/81702.rss" rel="self" type="application/rss+xml"/><pubDate>Tue, 25 Jul 2017 20:49:53 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to How can i extend the loops limit? on Sun, 06 Aug 2017 00:28:56 GMT]]></title><description><![CDATA[<p dir="auto">For debugging : <a href="https://www.youtube.com/watch?v=B7UsWtyhXh4" target="_blank" rel="noopener noreferrer nofollow ugc">https://www.youtube.com/watch?v=B7UsWtyhXh4</a></p>
<p dir="auto">qDebug() is a output stream special for debugging. It doesn't represent the debugging process in its whole.</p>
<p dir="auto">About QVector,I can see a lot of improvement here:</p>
<p dir="auto">First, You're not modifying your QVector, so you can put it const. This is useful to avoid bugs (Nice!)</p>
<p dir="auto">Second, because you're not inserting in the middle of the "Container" then you don't need QList (QList is much more inefficient that QVector)</p>
<p dir="auto">Third, QVector&lt;QString&gt; can be easily replaced by a QStringList. Look in documentation for its advantages.</p>
<p dir="auto">Then returning to the code:</p>
<p dir="auto">index in this way:</p>
<pre><code>while{
    if{
       }//end if
    else{

     }//end else
}//end while
</code></pre>
<p dir="auto">Regardless what <a class="plugin-mentions-user plugin-mentions-a" href="/user/eeli-k">@<bdi>Eeli-K</bdi></a>  said about qSort(), I think you need to practice more programming in general. Qt is facinating, all I know I learned programming in C++/Qt. Check some books, DEBUG, and enjoy.</p>
<p dir="auto">... If you finish debugging and you have a good question, please look at us.</p>
<p dir="auto">Thanks</p>
]]></description><link>https://forum.qt.io/post/408717</link><guid isPermaLink="true">https://forum.qt.io/post/408717</guid><dc:creator><![CDATA[Charlie_Hdz]]></dc:creator><pubDate>Sun, 06 Aug 2017 00:28:56 GMT</pubDate></item><item><title><![CDATA[Reply to How can i extend the loops limit? on Sat, 05 Aug 2017 09:40:08 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/eduardo12l">@<bdi>Eduardo12l</bdi></a> Now, immediately, learn to debug properly. Qt Creator has the Debug button ("play" arrow with a bug) under Run button, and also Debug top level menu item.</p>
<p dir="auto">Your code structure is something like</p>
<pre><code>if 
    for
        if
            while
                if
                else break
                if
                   for
                   for 
                       qSort(VectorAux.begin(), VectorAux.end());  
                       if 
                           if 
                           else if
                                 else
</code></pre>
<p dir="auto">First, it's difficult to read, understand or debug with any method and it's very error prone. After you have solved one problem you may run into another. You should rewrite it to be clear, easy and self-documenting. Second, you use qSort in n-th level inner loop which is probably inefficient (how many times it's executed?). Third, there might be (not necessarily) good candidates for C++ standard library algorithms like find_if which should be preferred to custom loops, both for error-freeness and readability.</p>
]]></description><link>https://forum.qt.io/post/408632</link><guid isPermaLink="true">https://forum.qt.io/post/408632</guid><dc:creator><![CDATA[Eeli K]]></dc:creator><pubDate>Sat, 05 Aug 2017 09:40:08 GMT</pubDate></item><item><title><![CDATA[Reply to How can i extend the loops limit? on Sat, 05 Aug 2017 03:43:56 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/charlie_hdz">@<bdi>Charlie_Hdz</bdi></a> i only use qdebug ¿Is there another way to check my code?<br />
Ps: Whats the problem with having a loop with a condition that is dynamic? Why do you recommend use QVector instead QList?</p>
]]></description><link>https://forum.qt.io/post/408614</link><guid isPermaLink="true">https://forum.qt.io/post/408614</guid><dc:creator><![CDATA[Eduardo12l]]></dc:creator><pubDate>Sat, 05 Aug 2017 03:43:56 GMT</pubDate></item><item><title><![CDATA[Reply to How can i extend the loops limit? on Sat, 05 Aug 2017 04:11:55 GMT]]></title><description><![CDATA[<p dir="auto">I have noticed that <strong>qDebug() &lt;&lt; entro</strong> is affecting my code in some way but i dont know how. Maybe memory being affected. if i erase that qDebug() &lt;&lt; entro it work. Wow it so rare</p>
<p dir="auto">Ps: The problem happens in the moment when a function is called.</p>
]]></description><link>https://forum.qt.io/post/408613</link><guid isPermaLink="true">https://forum.qt.io/post/408613</guid><dc:creator><![CDATA[Eduardo12l]]></dc:creator><pubDate>Sat, 05 Aug 2017 04:11:55 GMT</pubDate></item><item><title><![CDATA[Reply to How can i extend the loops limit? on Fri, 04 Aug 2017 22:44:41 GMT]]></title><description><![CDATA[<p dir="auto">First,</p>
<p dir="auto">Are you going to modify the DiasOrdenados, if not? Better use QVector.</p>
<p dir="auto">Then, your indexes are kind of confusing, please comment the end of the parenthesis.</p>
<p dir="auto">I Recommend you to debug, do you know how to debug?</p>
<p dir="auto">Thanks</p>
]]></description><link>https://forum.qt.io/post/408607</link><guid isPermaLink="true">https://forum.qt.io/post/408607</guid><dc:creator><![CDATA[Charlie_Hdz]]></dc:creator><pubDate>Fri, 04 Aug 2017 22:44:41 GMT</pubDate></item><item><title><![CDATA[Reply to How can i extend the loops limit? on Fri, 04 Aug 2017 22:25:33 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/charlie_hdz">@<bdi>Charlie_Hdz</bdi></a> But it can not be the problem because if i erase all the content of</p>
<pre><code>for(int i = 0; i &lt; DiasOrdenados.size(); i++
</code></pre>
<p dir="auto">Not only that part you said but all the content it continue failing. The difference happends when that <strong>for</strong> is present, that is the inflection point</p>
]]></description><link>https://forum.qt.io/post/408605</link><guid isPermaLink="true">https://forum.qt.io/post/408605</guid><dc:creator><![CDATA[Eduardo12l]]></dc:creator><pubDate>Fri, 04 Aug 2017 22:25:33 GMT</pubDate></item><item><title><![CDATA[Reply to How can i extend the loops limit? on Fri, 04 Aug 2017 21:55:32 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/eduardo12l">@<bdi>Eduardo12l</bdi></a></p>
<p dir="auto">Easy, You are modifying the Vector Aux size indirectly with the functions:</p>
<p dir="auto">Prepend()</p>
<p dir="auto">And RemoveAT()</p>
<p dir="auto">Please modify your implementation.</p>
]]></description><link>https://forum.qt.io/post/408599</link><guid isPermaLink="true">https://forum.qt.io/post/408599</guid><dc:creator><![CDATA[Charlie_Hdz]]></dc:creator><pubDate>Fri, 04 Aug 2017 21:55:32 GMT</pubDate></item><item><title><![CDATA[Reply to How can i extend the loops limit? on Fri, 04 Aug 2017 20:20:50 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/alexmal">@<bdi>AlexMal</bdi></a> <a class="plugin-mentions-user plugin-mentions-a" href="/user/charlie_hdz">@<bdi>Charlie_Hdz</bdi></a> <a class="plugin-mentions-user plugin-mentions-a" href="/user/jsulm">@<bdi>jsulm</bdi></a> <a class="plugin-mentions-user plugin-mentions-a" href="/user/sgaist">@<bdi>SGaist</bdi></a>  <a class="plugin-mentions-user plugin-mentions-a" href="/user/yuvaram">@<bdi>yuvaram</bdi></a>  Sorry for my english. As you can at the bottom of this comment <strong>on_pushbutton_clicked()</strong> should calls <strong>criterios()</strong> 10000 times. However, it crashes close to 6500. If I erase the content of this <strong>for</strong></p>
<pre><code> for(int i = 0; i &lt; DiasOrdenados.size(); i++)
</code></pre>
<p dir="auto">it continues crashing close to 6500. If I comment that loop  it does not crash <strong>(i mean // for(int i = 0; i &lt; DiasOrdenados.size(); i++))</strong>. I dont understand why that <strong>for</strong> is causing a crash.</p>
<p dir="auto">HEADER ventanas1.h</p>
<pre><code>n = 0;
QList&lt;QString&gt; DiasOrdenados &lt;&lt; LUNES &lt;&lt; MARTES &lt;&lt; MIERCOLES &lt;&lt; JUEVES &lt;&lt; VIERNES;
</code></pre>
<p dir="auto">SOURCE ventanas1.cpp</p>
<pre><code>void Ventanas1::on_pushButton_clicked(){
    n++;
    qDebug()&lt;&lt;"n es"&lt;&lt;n;
    val = 1;
    cont = 0;
    z = true;
    if(n &lt;= 10000){/ 
        criterios();
    }else{
        ui-&gt;pushButton-&gt;setStyleSheet   ("background-color: QLinearGradient(spread:pad x1: 0, y1: 0, x2: 0, y2: 1, stop: 0.0" + Vint[2][0] + ",  stop: 0.4" + Vint[2][1] + ", stop: 1.0"+ Vint[2][2]+");"
                                        "color: #868479; "
                                        "border-style: solid;"
                                        "border-style: solid;"
                                        "border-radius: 7;"
                                        "padding: 3px;"
                                        "padding-left: 5px;"
                                        "padding-right: 5px;"
                                        "border-color: #339;"
                                        "border-width: 1px;"
                                        "font:Bold;"
                                        "font-family:Georgia"); //Problema potencial 1. Solo una vez permite meterle el stylesheet.
        ui-&gt;pushButton-&gt;setText("No hay más\nopciones");
        ui-&gt;pushButton-&gt;setEnabled(false);
    }
}


void Ventanas1::criterios(){  
    if(Mnh &lt; 8){ 
        qDebug()&lt;&lt;"entro";
       umero = 0;
        for(int i = 0; i &lt; DiasOrdenados.size(); i++){ //In this for happends my problem
                if(DefDias.count(DiasOrdenados.at(i)) &gt; 0){ 
                cont = 0;
                val = 1;
                while(cont &lt; DefDias.size()){
                    if(DefDias.indexOf(DiasOrdenados.at(i),cont) != -1){ 
                        IndCriterios &lt;&lt; DefDias.indexOf(DiasOrdenados.at(i), cont);  
                        cont = DefDias.indexOf(DiasOrdenados.at(i), cont)+1; 
                    }else{ 
                        break;
                    }
                }
                if(IndCriterios.size() &gt; 1){
                   for(int j = 0; j &lt; IndCriterios.size(); j++){ 
                       VectorAux &lt;&lt; DefHoraF[IndCriterios[j&rsqb;&rsqb;;
                   }
                   for(int h = 0; h &lt; VectorAux.size(); h++){
                         VectorAux.prepend(DefHoraI[IndCriterios[h&rsqb;&rsqb;); 
                         qSort(VectorAux.begin(), VectorAux.end());  
                          if(VectorAux.at(0) != DefHoraI.at(IndCriterios[h])){ 
                              if(VectorAux.at(VectorAux.indexOf(DefHoraI[IndCriterios[h&rsqb;&rsqb;)-1) - DefHoraI.at(IndCriterios[h]) + Mth &lt; 0){ 
                                  val *= 0;
                                  numero++;
                              }else if(VectorAux.at(VectorAux.indexOf(DefHoraI[IndCriterios[h&rsqb;&rsqb;)-1) - DefHoraI.at(DefHoraI[IndCriterios[h&rsqb;&rsqb;) + Mth == Mth){ 
                                  val *= 1;
                              }else{
                                  numero++;
                                  val *= 1;
                              }
                          }
                          VectorAux.removeAt(VectorAux.indexOf(DefHoraI.at(IndCriterios[h]))); 
                   }
                }
                IndCriterios.clear();
                VectorAux.clear();
            }

        }
    }

    on_pushButton_clicked();
}
</code></pre>
<p dir="auto">PS: I dont know if recycling variables is causing that problem. Because I used some variables like <strong>cont</strong> and <strong>var</strong> several times in others  methods.</p>
]]></description><link>https://forum.qt.io/post/408585</link><guid isPermaLink="true">https://forum.qt.io/post/408585</guid><dc:creator><![CDATA[Eduardo12l]]></dc:creator><pubDate>Fri, 04 Aug 2017 20:20:50 GMT</pubDate></item><item><title><![CDATA[Reply to How can i extend the loops limit? on Wed, 26 Jul 2017 04:59:48 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/eduardo12l">@<bdi>Eduardo12l</bdi></a><br />
can you provide a sample code, it could help</p>
]]></description><link>https://forum.qt.io/post/406822</link><guid isPermaLink="true">https://forum.qt.io/post/406822</guid><dc:creator><![CDATA[yuvaram]]></dc:creator><pubDate>Wed, 26 Jul 2017 04:59:48 GMT</pubDate></item><item><title><![CDATA[Reply to How can i extend the loops limit? on Wed, 26 Jul 2017 04:48:11 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/eduardo12l">@<bdi>Eduardo12l</bdi></a> There is no such limit! So there is nothing to extend.<br />
You're doing something wrong in your code.<br />
But nobody can help you if you do not share your code!</p>
]]></description><link>https://forum.qt.io/post/406816</link><guid isPermaLink="true">https://forum.qt.io/post/406816</guid><dc:creator><![CDATA[jsulm]]></dc:creator><pubDate>Wed, 26 Jul 2017 04:48:11 GMT</pubDate></item><item><title><![CDATA[Reply to How can i extend the loops limit? on Wed, 26 Jul 2017 01:08:51 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/eduardo12l">@<bdi>Eduardo12l</bdi></a></p>
<p dir="auto">Please, give us more context if you want help... Specific questions.</p>
]]></description><link>https://forum.qt.io/post/406781</link><guid isPermaLink="true">https://forum.qt.io/post/406781</guid><dc:creator><![CDATA[Charlie_Hdz]]></dc:creator><pubDate>Wed, 26 Jul 2017 01:08:51 GMT</pubDate></item><item><title><![CDATA[Reply to How can i extend the loops limit? on Wed, 26 Jul 2017 01:08:24 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/eduardo12l">@<bdi>Eduardo12l</bdi></a> The problem is mostly likely not in a loop itself.<br />
For example - you allocate memory in the loop and exhaust your system or you are trying dereference a pointer which at a certain iteration become a null ...<br />
In any way get used to the fact that people to help you in general need to see the code.</p>
<p dir="auto">you do not mechanic " hey, my car stops 2 minutes after I  start engine, could you fix it without seen the car?"<br />
I like when people trust in me as I were a god, but I can't give you an useful answer.</p>
]]></description><link>https://forum.qt.io/post/406780</link><guid isPermaLink="true">https://forum.qt.io/post/406780</guid><dc:creator><![CDATA[AlexMal]]></dc:creator><pubDate>Wed, 26 Jul 2017 01:08:24 GMT</pubDate></item><item><title><![CDATA[Reply to How can i extend the loops limit? on Wed, 26 Jul 2017 00:31:24 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/sgaist">@<bdi>SGaist</bdi></a> <a class="plugin-mentions-user plugin-mentions-a" href="/user/alexmal">@<bdi>AlexMal</bdi></a> I notice that when i reduce the number of lines of my algorithm i get more loops.</p>
]]></description><link>https://forum.qt.io/post/406774</link><guid isPermaLink="true">https://forum.qt.io/post/406774</guid><dc:creator><![CDATA[Eduardo12l]]></dc:creator><pubDate>Wed, 26 Jul 2017 00:31:24 GMT</pubDate></item><item><title><![CDATA[Reply to How can i extend the loops limit? on Wed, 26 Jul 2017 00:05:11 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/eduardo12l">@<bdi>Eduardo12l</bdi></a><br />
you should debug and find where it crashes.<br />
Often crash happens due to problem close to the place it crashes in your code so you can review variables and find out why it crashes.</p>
<p dir="auto">If you are unable to do it yourself you display the part of the code around the crash (typically a function) and people might try to help you.<br />
What you stated provided no information which could help people even to guess. And no - there is no limits on the loops.</p>
]]></description><link>https://forum.qt.io/post/406771</link><guid isPermaLink="true">https://forum.qt.io/post/406771</guid><dc:creator><![CDATA[AlexMal]]></dc:creator><pubDate>Wed, 26 Jul 2017 00:05:11 GMT</pubDate></item><item><title><![CDATA[Reply to How can i extend the loops limit? on Tue, 25 Jul 2017 22:41:53 GMT]]></title><description><![CDATA[<p dir="auto">Hi,</p>
<p dir="auto">Find what makes it crash and then fix that.</p>
]]></description><link>https://forum.qt.io/post/406765</link><guid isPermaLink="true">https://forum.qt.io/post/406765</guid><dc:creator><![CDATA[SGaist]]></dc:creator><pubDate>Tue, 25 Jul 2017 22:41:53 GMT</pubDate></item></channel></rss>