View Full Version : how to do this ?
Petr_Kropotkin
11th February 2010, 03:21
I am writing a widget to display prime numbers.
How can i output the list of say first 1000 primes in Qt ?
ex code
for(prime=1;prime<1000;++primes)
cout<<primes<<endln
franz
11th February 2010, 06:54
Depends on what you want. You can put them in a QLabel or in a QStringListModel that is read by QListView.
Petr_Kropotkin
11th February 2010, 12:54
Readout should look like
1
3
5
7
11
.
.
.
.
997
Qlabel doesn't allow for scroll as far as I looked at the functions.
QStringListModel probablly then .
Maybe if the list primes is read into an array or something.
JD2000
12th February 2010, 14:13
Is this what you want?
QList<QString> primes;
primes << 1 << 2 << 3 << 5 << 7;
for (int i = 0; i < primes.size(); ++i) cout << primes.at(i) << endl;
if your programme is running from the command line, the output will probably be to the screen.
Under QT the output is likely to appear in the debug area.
Powered by vBulletin® Version 4.2.5 Copyright © 2024 vBulletin Solutions Inc. All rights reserved.