I am writing a widget to display prime numbers.
How can i output the list of say first 1000 primes in Qt ?
ex code
Qt Code:
for(prime=1;prime<1000;++primes) cout<<primes<<endlnTo copy to clipboard, switch view to plain text mode
I am writing a widget to display prime numbers.
How can i output the list of say first 1000 primes in Qt ?
ex code
Qt Code:
for(prime=1;prime<1000;++primes) cout<<primes<<endlnTo copy to clipboard, switch view to plain text mode
Depends on what you want. You can put them in a QLabel or in a QStringListModel that is read by QListView.
Horse sense is the thing that keeps horses from betting on people. --W.C. Fields
Ask Smart Questions
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.
Is this what you want?
Qt Code:
QList<QString> primes; primes << 1 << 2 << 3 << 5 << 7; for (int i = 0; i < primes.size(); ++i) cout << primes.at(i) << endl;To copy to clipboard, switch view to plain text mode
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.
Bookmarks