Search code examples
c++qteigenqtguiqtcore

Convert eigen vector to QString for display


What is the easiest way to print a vector from the Eigen library in a Qt interface?

Is there an easy way to convert the vector to a QString so that I can use setText()?

Or is there an easier way of doing it?


Solution

  • I would write the following for an N dimension vector:

    QString myString;
    for (int i = 0; i < svector; ++i)
        myString.append(QString(vector[i]) + "\n");
    myLabel.setText(myString);