Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. How to convert QList<QUrl> into a QString?
Forum Updated to NodeBB v4.3 + New Features

How to convert QList<QUrl> into a QString?

Scheduled Pinned Locked Moved Solved General and Desktop
3 Posts 2 Posters 283 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    mrflores
    wrote on last edited by
    #1

    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.

    1 Reply Last reply
    0
    • C Offline
      C Offline
      ChrisW67
      wrote on last edited by
      #2

      @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;
      }
      
      1 Reply Last reply
      4
      • M Offline
        M Offline
        mrflores
        wrote on last edited by
        #3

        Thank you so much, this saved my life! Ive been trying to figure this out for my classes final project and dont know why I struggled with this so much. It was so obvious lmaoo.

        1 Reply Last reply
        0

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved