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. [SOLVED]display image through http url
Forum Updated to NodeBB v4.3 + New Features

[SOLVED]display image through http url

Scheduled Pinned Locked Moved General and Desktop
12 Posts 4 Posters 28.1k Views 1 Watching
  • 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.
  • H Offline
    H Offline
    HuXiKa
    wrote on last edited by
    #2

    You want to download an image and diplay it? Or what do you mean under "display an image through url" ?

    If you can find faults of spelling in the text above, you can keep them.

    1 Reply Last reply
    0
    • A Offline
      A Offline
      andre
      wrote on last edited by
      #3

      In the widget world, you can not do that directly.
      You'll have to download the image using QNetworkAccessManager, and set the resulting image on the label.

      1 Reply Last reply
      0
      • T Offline
        T Offline
        TobbY
        wrote on last edited by
        #4

        thanks, it is really helpfull.

        1 Reply Last reply
        0
        • T Offline
          T Offline
          TobbY
          wrote on last edited by
          #5

          can anyone give me an example to do that???

          1 Reply Last reply
          0
          • H Offline
            H Offline
            HuXiKa
            wrote on last edited by
            #6

            @
            QNetworkAccessManager m_netwManager = new QNetworkAccessManager(this);
            connect(m_netwManager, SIGNAL(finished(QNetworkReply*)), this, SLOT(slot_netwManagerFinished(QNetworkReply*)));

            QUrl url("http://....");
            QNetworkRequest request(url);
            m_netwManager->get(request);
            @

            the slot:

            @
            void MainWindow::slot_netwManagerFinished(QNetworkReply *reply)
            {
            if (reply->error() != QNetworkReply::NoError) {
            qDebug() << "Error in" << reply->url() << ":" << reply->errorString();
            return;
            }

            QByteArray jpegData = reply->readAll();
            QPixmap pixmap;
            pixmap.loadFromData(jpegData);
            label->setPixmap(pixmap); // or whatever your labels name is
            

            }@

            Took me 20 secs with google to find "this":http://www.qtforum.org/article/33674/how-can-i-download-an-image-from-an-http-url.html.

            If you can find faults of spelling in the text above, you can keep them.

            1 Reply Last reply
            0
            • A Offline
              A Offline
              andre
              wrote on last edited by
              #7

              While the above is a good outline of what to do, don't forget to add error checking at the appropriate places in this code.

              1 Reply Last reply
              0
              • T Offline
                T Offline
                TobbY
                wrote on last edited by
                #8

                release/mainwindow.o:mainwindow.cpp:(.text+0xa1e): undefined reference to _imp___ZN21QNetworkAccessManagerC1EP7QObject' release/mainwindow.o:mainwindow.cpp:(.text+0xa75): undefined reference to _imp___ZN15QNetworkRequestC1ERK4QUrl'
                release/mainwindow.o:mainwindow.cpp:(.text+0xa88): undefined reference to _imp___ZN21QNetworkAccessManager3getERK15QNetworkRequest' release/mainwindow.o:mainwindow.cpp:(.text+0xa91): undefined reference to _imp___ZN15QNetworkRequestD1Ev'
                release/mainwindow.o:mainwindow.cpp:(.text+0xf1d): undefined reference to _imp___ZN15QNetworkRequestD1Ev' release/mainwindow.o:mainwindow.cpp:(.text+0x19aa): undefined reference to _imp___ZN21QNetworkAccessManagerC1EP7QObject'
                release/mainwindow.o:mainwindow.cpp:(.text+0x1a01): undefined reference to _imp___ZN15QNetworkRequestC1ERK4QUrl' release/mainwindow.o:mainwindow.cpp:(.text+0x1a14): undefined reference to _imp___ZN21QNetworkAccessManager3getERK15QNetworkRequest'
                release/mainwindow.o:mainwindow.cpp:(.text+0x1a1d): undefined reference to _imp___ZN15QNetworkRequestD1Ev' release/mainwindow.o:mainwindow.cpp:(.text+0x1e60): undefined reference to _imp___ZN15QNetworkRequestD1Ev'
                collect2: ld returned 1 exit status

                this error occured... is there any library i need to include*

                1 Reply Last reply
                0
                • T Offline
                  T Offline
                  TobbY
                  wrote on last edited by
                  #9

                  this is my pro file

                  @

                  Add files and directories to ship with the application

                  by adapting the examples below.

                  file1.source = myfile

                  dir1.source = mydir

                  DEPLOYMENTFOLDERS = # file1 dir1

                  Avoid auto screen rotation

                  #DEFINES += ORIENTATIONLOCK

                  Needs to be defined for Symbian

                  #DEFINES += NETWORKACCESS
                  QT+= core gui networks
                  symbian:TARGET.UID3 = 0xE5E25B16

                  LIBS += C:\QtSDK\mingw\lib\libws2_32.a

                  If your application uses the Qt Mobility libraries, uncomment

                  the following lines and add the respective components to the

                  MOBILITY variable.

                  CONFIG += mobility

                  MOBILITY +=

                  SOURCES += main.cpp mainwindow.cpp
                  soapClient.cpp
                  soapC.cpp
                  stdsoap2.cpp
                  HEADERS += mainwindow.h
                  soapStub.h
                  soapH.h
                  soapBasicHttpBinding_USCOREIClientServiceProxy.h
                  stdsoap2.h
                  FORMS += mainwindow.ui

                  Please do not modify the following two lines. Required for deployment.

                  include(deployment.pri)
                  qtcAddDeployment()

                  OTHER_FILES +=
                  BasicHttpBinding_USCOREIClientService.nsmap
                  @

                  [EDIT: code formatting, please wrap in @-tags, Volker]

                  1 Reply Last reply
                  0
                  • F Offline
                    F Offline
                    Franzk
                    wrote on last edited by
                    #10

                    Isn't the module called network instead of networks?

                    "Horse sense is the thing a horse has which keeps it from betting on people." -- W.C. Fields

                    http://www.catb.org/~esr/faqs/smart-questions.html

                    1 Reply Last reply
                    0
                    • T Offline
                      T Offline
                      TobbY
                      wrote on last edited by
                      #11

                      :-) sorry, my mistake

                      1 Reply Last reply
                      0
                      • F Offline
                        F Offline
                        Franzk
                        wrote on last edited by
                        #12

                        [quote author="TobbY" date="1308721124"]:-) sorry, my mistake[/quote]Qt DevNet: If we point at something, it's bound to be a mistake. :P

                        "Horse sense is the thing a horse has which keeps it from betting on people." -- W.C. Fields

                        http://www.catb.org/~esr/faqs/smart-questions.html

                        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