Hello,
i want to display an array of integers, how can i do that please?
Thank you.
Hello,
i want to display an array of integers, how can i do that please?
Thank you.
There are so many ways that you will need to be a bit more precise on what you need.
Cheers,
_
i want to code a merge sort algorithm, but just to start i want to display for example a QVector of 10 elements, just for the interface
i want to display this vector
Qt Code:
#include <QApplication> #include <QtWidgets> int main(int argc, char *argv[]) { QWidget f; QVector<int> vector(5); for (int i=0;i< vector.size(); i++) { vector[i]=i; } f.show(); return app.exec(); }To copy to clipboard, switch view to plain text mode
Last edited by rafik; 4th February 2016 at 18:49.
The easiest way I can think of is to create a string that contains all numbers and display that in a QLabel
Qt Code:
QStringList items; foreach (const int number, vector) { } label->setText(items.join(", "));To copy to clipboard, switch view to plain text mode
Alternatively with a QListWidget
Qt Code:
foreach (const int number, vector) { }To copy to clipboard, switch view to plain text mode
Cheers,
_
rafik (6th February 2016)
Thank you Mr anda, with your second example QListWidget i get what i want. thanks![]()
Bookmarks