<?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[Why don&#x27;t I get an updated list of values via drawShapes]]></title><description><![CDATA[<p dir="auto">lottery.cpp</p>
<p dir="auto">when I hit select drawShapes does not update 54 values</p>
<p dir="auto">@<br />
#include "lottery.h"<br />
#include &lt;QSet&gt;<br />
#include &lt;QtDebug&gt;<br />
#include &lt;QPainter&gt;</p>
<p dir="auto">Lottery::Lottery(QWidget *parent)<br />
: QWidget(parent)<br />
{<br />
ui.setupUi(this);<br />
connect( ui.pushButton, SIGNAL(clicked()), this, SLOT(selectClicked()) );<br />
}</p>
<p dir="auto">Lottery::~Lottery()<br />
{</p>
<p dir="auto">}<br />
void Lottery::selectClicked()<br />
{<br />
int value;<br />
int M = 53;<br />
int intArray[6];<br />
QSet&lt;int&gt; set;<br />
set.reserve(6);<br />
srand(time(0));<br />
ui.listWidget-&gt;addItem(QString("server StartTCPServer"));<br />
do<br />
{<br />
value = (int)( M*(double)rand()/((double)RAND_MAX+(double)1))+1;</p>
<pre><code> set.insert(value);
} while(set.size()&lt;6);


int j = 0;
QSet&lt;int&gt;::const_iterator i = set.begin();
while (i != set.end()) {
    intArray[j] = *i;
    histo[intArray[j&rsqb;&rsqb;++;
    ++i;++j;
}
QString qstring1;
qstring1.setNum(intArray[0]);
ui.lineEdit_1-&gt;setText(qstring1);

qstring1.setNum(intArray[1]);
ui.lineEdit_2-&gt;setText(qstring1);
 
qstring1.setNum(intArray[2]);
ui.lineEdit_3-&gt;setText(qstring1);
  
qstring1.setNum(intArray[3]);
ui.lineEdit_4-&gt;setText(qstring1);
   
qstring1.setNum(intArray[4]);
ui.lineEdit_5-&gt;setText(qstring1);
    
qstring1.setNum(intArray[5]);
ui.lineEdit_6-&gt;setText(qstring1);

QPainter paint( this );
drawShapes(&amp;paint);
</code></pre>
<p dir="auto">}<br />
void Lottery::paintEvent( QPaintEvent* qpe) {<br />
// fout&lt;&lt;"DrawView::paintEvent"&lt;&lt;endl;</p>
<pre><code>QPainter paint( this );
drawShapes(&amp;paint);
qpaintevent = qpe;
</code></pre>
<p dir="auto">}<br />
void Lottery::drawShapes( QPainter *p ) {<br />
setGeometry(100,100,800,800);<br />
p-&gt;setPen( Qt::black);<br />
QFont qf;<br />
qf.setStyle(QFont::StyleNormal);<br />
qf.setWeight(QFont::Light);<br />
p-&gt;setFont(qf);<br />
QString qstr1;<br />
QString qstr2;<br />
int ix = 300;<br />
int iy = 20;<br />
for(int i = 1; i&lt;54;i++)<br />
{<br />
qstr1.setNum(i);<br />
qstr2.setNum(histo[i]);<br />
p-&gt;drawText(ix, iy,"number of "+qstr1+"="+qstr2);<br />
iy+=15;<br />
}</p>
<p dir="auto">}</p>
<p dir="auto">@</p>
<p dir="auto">lottery,h</p>
<p dir="auto">@</p>
<p dir="auto">#ifndef LOTTERY_H<br />
#define LOTTERY_H</p>
<p dir="auto">#include &lt;QtGui/QWidget&gt;<br />
#include "ui_lottery.h"<br />
#include &lt;QMap&gt;<br />
#include &lt;QPaintEvent&gt;<br />
class Lottery : public QWidget<br />
{<br />
Q_OBJECT</p>
<p dir="auto">public:<br />
Lottery(QWidget *parent = 0);<br />
~Lottery();</p>
<p dir="auto">private:<br />
Ui::LotteryClass ui;<br />
void   paintEvent( QPaintEvent * );<br />
QMap&lt;int,int&gt; histo;<br />
QPaintEvent* qpaintevent;<br />
void drawShapes( QPainter *p );<br />
private slots:<br />
void selectClicked();<br />
};</p>
<p dir="auto">#endif // LOTTERY_H<br />
@</p>
]]></description><link>https://forum.qt.io/topic/16256/why-don-t-i-get-an-updated-list-of-values-via-drawshapes</link><generator>RSS for Node</generator><lastBuildDate>Wed, 23 Sep 2026 10:10:39 GMT</lastBuildDate><atom:link href="https://forum.qt.io/topic/16256.rss" rel="self" type="application/rss+xml"/><pubDate>Fri, 27 Apr 2012 15:39:50 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Why don&#x27;t I get an updated list of values via drawShapes on Sat, 28 Apr 2012 00:18:51 GMT]]></title><description><![CDATA[<p dir="auto">by Jove Olde Beane...think you got it</p>
<p dir="auto">it works! thanks!</p>
<p dir="auto">I had tried repaint() but put it in the wrong place</p>
]]></description><link>https://forum.qt.io/post/137305</link><guid isPermaLink="true">https://forum.qt.io/post/137305</guid><dc:creator><![CDATA[[[global:former-user]]]]></dc:creator><pubDate>Sat, 28 Apr 2012 00:18:51 GMT</pubDate></item><item><title><![CDATA[Reply to Why don&#x27;t I get an updated list of values via drawShapes on Fri, 27 Apr 2012 16:40:17 GMT]]></title><description><![CDATA[<p dir="auto">sorry the range for each lottery entry is 1-53</p>
<p dir="auto">in each of the 6 positions</p>
<p dir="auto">Not a lottery player but it is great learning tool</p>
<p dir="auto">when I click on select, I should get the 53 values in the histogram updated</p>
]]></description><link>https://forum.qt.io/post/137278</link><guid isPermaLink="true">https://forum.qt.io/post/137278</guid><dc:creator><![CDATA[[[global:former-user]]]]></dc:creator><pubDate>Fri, 27 Apr 2012 16:40:17 GMT</pubDate></item><item><title><![CDATA[Reply to Why don&#x27;t I get an updated list of values via drawShapes on Fri, 27 Apr 2012 16:24:22 GMT]]></title><description><![CDATA[<p dir="auto">ui_lottery.h<br />
@<br />
&lt;ui version="4.0" &gt;<br />
&lt;class&gt;LotteryClass&lt;/class&gt;<br />
&lt;widget class="QWidget" name="LotteryClass" &gt;<br />
&lt;property name="geometry" &gt;<br />
&lt;rect&gt;<br />
&lt;x&gt;0&lt;/x&gt;<br />
&lt;y&gt;0&lt;/y&gt;<br />
&lt;width&gt;400&lt;/width&gt;<br />
&lt;height&gt;528&lt;/height&gt;<br />
&lt;/rect&gt;<br />
&lt;/property&gt;<br />
&lt;property name="font" &gt;<br />
&lt;font&gt;<br />
&lt;weight&gt;75&lt;/weight&gt;<br />
&lt;bold&gt;true&lt;/bold&gt;<br />
&lt;/font&gt;<br />
&lt;/property&gt;<br />
&lt;property name="mouseTracking" &gt;<br />
&lt;bool&gt;false&lt;/bool&gt;<br />
&lt;/property&gt;<br />
&lt;property name="windowTitle" &gt;<br />
&lt;string&gt;Lottery&lt;/string&gt;<br />
&lt;/property&gt;<br />
&lt;widget class="QPushButton" name="pushButton" &gt;<br />
&lt;property name="geometry" &gt;<br />
&lt;rect&gt;<br />
&lt;x&gt;70&lt;/x&gt;<br />
&lt;y&gt;230&lt;/y&gt;<br />
&lt;width&gt;83&lt;/width&gt;<br />
&lt;height&gt;30&lt;/height&gt;<br />
&lt;/rect&gt;<br />
&lt;/property&gt;<br />
&lt;property name="text" &gt;<br />
&lt;string&gt;select&lt;/string&gt;<br />
&lt;/property&gt;<br />
&lt;/widget&gt;<br />
&lt;widget class="QPushButton" name="pushButtonClose" &gt;<br />
&lt;property name="geometry" &gt;<br />
&lt;rect&gt;<br />
&lt;x&gt;70&lt;/x&gt;<br />
&lt;y&gt;290&lt;/y&gt;<br />
&lt;width&gt;83&lt;/width&gt;<br />
&lt;height&gt;30&lt;/height&gt;<br />
&lt;/rect&gt;<br />
&lt;/property&gt;<br />
&lt;property name="text" &gt;<br />
&lt;string&gt;Close&lt;/string&gt;<br />
&lt;/property&gt;<br />
&lt;/widget&gt;<br />
&lt;widget class="QWidget" name="layoutWidget" &gt;<br />
&lt;property name="geometry" &gt;<br />
&lt;rect&gt;<br />
&lt;x&gt;40&lt;/x&gt;<br />
&lt;y&gt;20&lt;/y&gt;<br />
&lt;width&gt;146&lt;/width&gt;<br />
&lt;height&gt;194&lt;/height&gt;<br />
&lt;/rect&gt;<br />
&lt;/property&gt;<br />
&lt;layout class="QVBoxLayout" name="verticalLayout" &gt;<br />
&lt;item&gt;<br />
&lt;widget class="QLineEdit" name="lineEdit_1" /&gt;<br />
&lt;/item&gt;<br />
&lt;item&gt;<br />
&lt;widget class="QLineEdit" name="lineEdit_2" /&gt;<br />
&lt;/item&gt;<br />
&lt;item&gt;<br />
&lt;widget class="QLineEdit" name="lineEdit_3" /&gt;<br />
&lt;/item&gt;<br />
&lt;item&gt;<br />
&lt;widget class="QLineEdit" name="lineEdit_4" /&gt;<br />
&lt;/item&gt;<br />
&lt;item&gt;<br />
&lt;widget class="QLineEdit" name="lineEdit_5" /&gt;<br />
&lt;/item&gt;<br />
&lt;item&gt;<br />
&lt;widget class="QLineEdit" name="lineEdit_6" /&gt;<br />
&lt;/item&gt;<br />
&lt;/layout&gt;<br />
&lt;/widget&gt;<br />
&lt;widget class="QListWidget" name="listWidget" &gt;<br />
&lt;property name="geometry" &gt;<br />
&lt;rect&gt;<br />
&lt;x&gt;70&lt;/x&gt;<br />
&lt;y&gt;330&lt;/y&gt;<br />
&lt;width&gt;171&lt;/width&gt;<br />
&lt;height&gt;111&lt;/height&gt;<br />
&lt;/rect&gt;<br />
&lt;/property&gt;<br />
&lt;/widget&gt;<br />
&lt;/widget&gt;<br />
&lt;layoutdefault spacing="6" margin="11" /&gt;<br />
&lt;resources/&gt;<br />
&lt;connections&gt;<br />
&lt;connection&gt;<br />
&lt;sender&gt;pushButtonClose&lt;/sender&gt;<br />
&lt;signal&gt;clicked()&lt;/signal&gt;<br />
&lt;receiver&gt;LotteryClass&lt;/receiver&gt;<br />
&lt;slot&gt;close()&lt;/slot&gt;<br />
&lt;hints&gt;<br />
&lt;hint type="sourcelabel" &gt;<br />
&lt;x&gt;111&lt;/x&gt;<br />
&lt;y&gt;304&lt;/y&gt;<br />
&lt;/hint&gt;<br />
&lt;hint type="destinationlabel" &gt;<br />
&lt;x&gt;199&lt;/x&gt;<br />
&lt;y&gt;263&lt;/y&gt;<br />
&lt;/hint&gt;<br />
&lt;/hints&gt;<br />
&lt;/connection&gt;<br />
&lt;/connections&gt;<br />
&lt;/ui&gt;<br />
@</p>
]]></description><link>https://forum.qt.io/post/137275</link><guid isPermaLink="true">https://forum.qt.io/post/137275</guid><dc:creator><![CDATA[[[global:former-user]]]]></dc:creator><pubDate>Fri, 27 Apr 2012 16:24:22 GMT</pubDate></item><item><title><![CDATA[Reply to Why don&#x27;t I get an updated list of values via drawShapes on Fri, 27 Apr 2012 16:20:11 GMT]]></title><description><![CDATA[<p dir="auto">Instead of doing:<br />
@<br />
QPainter paint( this );<br />
drawShapes(&amp;paint);<br />
@</p>
<p dir="auto">in your selectClicked() method, use<br />
@<br />
repaint();<br />
@</p>
]]></description><link>https://forum.qt.io/post/137273</link><guid isPermaLink="true">https://forum.qt.io/post/137273</guid><dc:creator><![CDATA[mlong]]></dc:creator><pubDate>Fri, 27 Apr 2012 16:20:11 GMT</pubDate></item><item><title><![CDATA[Reply to Why don&#x27;t I get an updated list of values via drawShapes on Fri, 27 Apr 2012 16:10:10 GMT]]></title><description><![CDATA[<p dir="auto">there are 53 values in the lottery for each of 6 positions</p>
<p dir="auto">not 54...sorry!</p>
<p dir="auto">1-53</p>
<p dir="auto">@<br />
/********************************************************************************<br />
** Form generated from reading UI file 'lottery.ui'<br />
**<br />
** Created by: Qt User Interface Compiler version 4.8.1<br />
**<br />
** WARNING! All changes made in this file will be lost when recompiling UI file!<br />
********************************************************************************/</p>
<p dir="auto">#ifndef UI_LOTTERY_H<br />
#define UI_LOTTERY_H</p>
<p dir="auto">#include &lt;QtCore/QVariant&gt;<br />
#include &lt;QtGui/QAction&gt;<br />
#include &lt;QtGui/QApplication&gt;<br />
#include &lt;QtGui/QButtonGroup&gt;<br />
#include &lt;QtGui/QHeaderView&gt;<br />
#include &lt;QtGui/QLineEdit&gt;<br />
#include &lt;QtGui/QListWidget&gt;<br />
#include &lt;QtGui/QPushButton&gt;<br />
#include &lt;QtGui/QVBoxLayout&gt;<br />
#include &lt;QtGui/QWidget&gt;</p>
<p dir="auto">QT_BEGIN_NAMESPACE</p>
<p dir="auto">class Ui_LotteryClass<br />
{<br />
public:<br />
QPushButton *pushButton;<br />
QPushButton *pushButtonClose;<br />
QWidget *layoutWidget;<br />
QVBoxLayout *verticalLayout;<br />
QLineEdit *lineEdit_1;<br />
QLineEdit *lineEdit_2;<br />
QLineEdit *lineEdit_3;<br />
QLineEdit *lineEdit_4;<br />
QLineEdit *lineEdit_5;<br />
QLineEdit *lineEdit_6;<br />
QListWidget *listWidget;</p>
<pre><code>void setupUi(QWidget *LotteryClass)
{
    if (LotteryClass-&gt;objectName().isEmpty())
        LotteryClass-&gt;setObjectName(QString::fromUtf8("LotteryClass"));
    LotteryClass-&gt;resize(400, 528);
    QFont font;
    font.setBold(true);
    font.setWeight(75);
    LotteryClass-&gt;setFont(font);
    LotteryClass-&gt;setMouseTracking(false);
    pushButton = new QPushButton(LotteryClass);
    pushButton-&gt;setObjectName(QString::fromUtf8("pushButton"));
    pushButton-&gt;setGeometry(QRect(70, 230, 83, 30));
    pushButtonClose = new QPushButton(LotteryClass);
    pushButtonClose-&gt;setObjectName(QString::fromUtf8("pushButtonClose"));
    pushButtonClose-&gt;setGeometry(QRect(70, 290, 83, 30));
    layoutWidget = new QWidget(LotteryClass);
    layoutWidget-&gt;setObjectName(QString::fromUtf8("layoutWidget"));
    layoutWidget-&gt;setGeometry(QRect(40, 20, 146, 194));
    verticalLayout = new QVBoxLayout(layoutWidget);
    verticalLayout-&gt;setSpacing(6);
    verticalLayout-&gt;setContentsMargins(11, 11, 11, 11);
    verticalLayout-&gt;setObjectName(QString::fromUtf8("verticalLayout"));
    verticalLayout-&gt;setContentsMargins(0, 0, 0, 0);
    lineEdit_1 = new QLineEdit(layoutWidget);
    lineEdit_1-&gt;setObjectName(QString::fromUtf8("lineEdit_1"));

    verticalLayout-&gt;addWidget(lineEdit_1);

    lineEdit_2 = new QLineEdit(layoutWidget);
    lineEdit_2-&gt;setObjectName(QString::fromUtf8("lineEdit_2"));

    verticalLayout-&gt;addWidget(lineEdit_2);

    lineEdit_3 = new QLineEdit(layoutWidget);
    lineEdit_3-&gt;setObjectName(QString::fromUtf8("lineEdit_3"));

    verticalLayout-&gt;addWidget(lineEdit_3);

    lineEdit_4 = new QLineEdit(layoutWidget);
    lineEdit_4-&gt;setObjectName(QString::fromUtf8("lineEdit_4"));

    verticalLayout-&gt;addWidget(lineEdit_4);

    lineEdit_5 = new QLineEdit(layoutWidget);
    lineEdit_5-&gt;setObjectName(QString::fromUtf8("lineEdit_5"));

    verticalLayout-&gt;addWidget(lineEdit_5);

    lineEdit_6 = new QLineEdit(layoutWidget);
    lineEdit_6-&gt;setObjectName(QString::fromUtf8("lineEdit_6"));

    verticalLayout-&gt;addWidget(lineEdit_6);

    listWidget = new QListWidget(LotteryClass);
    listWidget-&gt;setObjectName(QString::fromUtf8("listWidget"));
    listWidget-&gt;setGeometry(QRect(70, 330, 171, 111));

    retranslateUi(LotteryClass);
    QObject::connect(pushButtonClose, SIGNAL(clicked()), LotteryClass, SLOT(close()));

    QMetaObject::connectSlotsByName(LotteryClass);
} // setupUi

void retranslateUi(QWidget *LotteryClass)
{
    LotteryClass-&gt;setWindowTitle(QApplication::translate("LotteryClass", "Lottery", 0, QApplication::UnicodeUTF8));
    pushButton-&gt;setText(QApplication::translate("LotteryClass", "select", 0, QApplication::UnicodeUTF8));
    pushButtonClose-&gt;setText(QApplication::translate("LotteryClass", "Close", 0, QApplication::UnicodeUTF8));
} // retranslateUi
</code></pre>
<p dir="auto">};</p>
<p dir="auto">namespace Ui {<br />
class LotteryClass: public Ui_LotteryClass {};<br />
} // namespace Ui</p>
<p dir="auto">QT_END_NAMESPACE</p>
<p dir="auto">#endif // UI_LOTTERY_H</p>
<p dir="auto">@</p>
]]></description><link>https://forum.qt.io/post/137272</link><guid isPermaLink="true">https://forum.qt.io/post/137272</guid><dc:creator><![CDATA[[[global:former-user]]]]></dc:creator><pubDate>Fri, 27 Apr 2012 16:10:10 GMT</pubDate></item><item><title><![CDATA[Reply to Why don&#x27;t I get an updated list of values via drawShapes on Fri, 27 Apr 2012 16:06:30 GMT]]></title><description><![CDATA[<p dir="auto">I get 53 values right out of the starting gate all zero of course</p>
<p dir="auto">when I hit the select button, the "histogram" values are not updated</p>
<p dir="auto">with the current lottery values</p>
<p dir="auto">If I minimize/maximize, the values are updated</p>
<p dir="auto">drawShapes needs a paintEvent I guess</p>
<p dir="auto">if you win a lottery using my program, you owe me half...ha!</p>
]]></description><link>https://forum.qt.io/post/137271</link><guid isPermaLink="true">https://forum.qt.io/post/137271</guid><dc:creator><![CDATA[[[global:former-user]]]]></dc:creator><pubDate>Fri, 27 Apr 2012 16:06:30 GMT</pubDate></item><item><title><![CDATA[Reply to Why don&#x27;t I get an updated list of values via drawShapes on Fri, 27 Apr 2012 15:54:32 GMT]]></title><description><![CDATA[<p dir="auto">How many are you getting?</p>
<p dir="auto">Your draw loop at line 83 above has:<br />
@<br />
for(int i = 1; i&lt;54;i++)<br />
@</p>
<p dir="auto">which will only draw 53 items, skipping element 0.</p>
]]></description><link>https://forum.qt.io/post/137269</link><guid isPermaLink="true">https://forum.qt.io/post/137269</guid><dc:creator><![CDATA[mlong]]></dc:creator><pubDate>Fri, 27 Apr 2012 15:54:32 GMT</pubDate></item></channel></rss>