How to convert QList<QUrl> into a QString?
Solved
General and Desktop
-
Hey guys,
Right now ive got a list of URL's that's stored as QList<Qurl> myList. Im trying to take each url out and print it to a textWidget but am running into some trouble. So how can I convert these URLs from the list so I can just do ui->textEdit->append(myList)? I wouldve thought I could access myList[i] using a for loop and print it that way, but was wrong.
-
@mrflores said in How to convert QList<QUrl> into a QString?:
ui->textEdit->append(myList)
That is never going to work because there's no QTextEdit method taking a QList<QUrl>.
wouldve thought I could access myList[i] using a for loop and print it that way, but was wrong.
You mean this does not work?
#include <QCoreApplication> #include <QUrl> #include <QList> #include <QString> #include <QDebug> int main(int argc, char *argv[]) { QCoreApplication a(argc, argv); QList<QUrl> myList = { QUrl("https://forum.qt.io"), QUrl("https://google.com") }; QString text; for (int i = 0; i < myList.size(); ++i) text += myList.at(i).toString() + " "; qDebug() << text; return 0; }