跳到內容
  • 版面
  • 最新
  • 標籤
  • 熱門
  • 使用者
  • 群組
  • 搜尋
  • Get Qt Extensions
  • Unsolved
Collapse
品牌標誌
  1. 首頁
  2. Qt Development
  3. QML and Qt Quick
  4. QML Image: TLS initialization failed
Forum Updated to NodeBB v4.3 + New Features

QML Image: TLS initialization failed

已排程 已置頂 已鎖定 已移動 Solved QML and Qt Quick
24 貼文 4 Posters 4.0k 瀏覽 3 Watching
  • 從舊到新
  • 從新到舊
  • 最多點贊
回覆
  • 在新貼文中回覆
登入後回覆
此主題已被刪除。只有擁有主題管理權限的使用者可以查看。
  • Q 離線
    Q 離線
    qcoderpro
    寫於 最後由 編輯
    #1

    I get the error: qrc:/main.qml:4:1: QML Image: TLS initialization failed for Image (line 4) when running the QML project below:

    import QtQuick 2.15
    import QtQuick.Window 2.15
    
    Image {
       id: europe
       width: 1000; height: 1000
       source: "https://cdn.britannica.com/s:300x169,c:crop/67/367-050-0F839196/Europe.jpg"
       fillMode: Image.PreserveAspectFit
    
       Rectangle {
           x: 0; y: 950
           color: "dodgerblue"
           height: 50
           width: 1000 * europe.progress
           visible: europe.progress != 1
       }
    }
    
    1 條回覆 最後回覆
    0
    • Q qcoderpro

      Now when I run the project, Issues, Compile Output and General Messages windows show nothing. Only Application Output shows this:
      Starting ... build-QML_5-Desktop_Qt_5_15_2_MinGW_64_bit-Debug\QML_5.exe ... which shows nothing bad!

      So why still nothing as output is shown? :(

      tomyT 離線
      tomyT 離線
      tomy
      寫於 最後由 tomy 編輯
      #24

      @qcoderpro

      Put your image element inside a window element. It's required to me.

      1 條回覆 最後回覆
      1
      • sierdzioS 離線
        sierdzioS 離線
        sierdzio
        Moderators
        寫於 最後由 編輯
        #2

        You need to use OpenSSL in your project - link OpenSSL libs with your application and it should start working.

        Some docs:

        • https://doc.qt.io/qt-5.12/ssl.html
        • https://doc.qt.io/qt-5/android-openssl-support.html

        (Z(:^

        Q 1 條回覆 最後回覆
        2
        • sierdzioS sierdzio

          You need to use OpenSSL in your project - link OpenSSL libs with your application and it should start working.

          Some docs:

          • https://doc.qt.io/qt-5.12/ssl.html
          • https://doc.qt.io/qt-5/android-openssl-support.html
          Q 離線
          Q 離線
          qcoderpro
          寫於 最後由 編輯
          #3

          @sierdzio

          It says: By default, an SSL-enabled Qt library dynamically loads any installed OpenSSL library at run-time

          I'm on Windows.

          1 條回覆 最後回覆
          0
          • sierdzioS 離線
            sierdzioS 離線
            sierdzio
            Moderators
            寫於 最後由 編輯
            #4

            Yes, well there isn't any installed OpenSSL library on Windows :D

            (Z(:^

            Q 1 條回覆 最後回覆
            0
            • sierdzioS sierdzio

              Yes, well there isn't any installed OpenSSL library on Windows :D

              Q 離線
              Q 離線
              qcoderpro
              寫於 最後由 qcoderpro 編輯
              #5

              @sierdzio

              But I've installed OpenSSL using Qt!
              You mean I can't load an image from the Internet on Windows!?

              This guy is running that project on Windows successfully!

              sierdzioS 1 條回覆 最後回覆
              0
              • Q qcoderpro

                @sierdzio

                But I've installed OpenSSL using Qt!
                You mean I can't load an image from the Internet on Windows!?

                This guy is running that project on Windows successfully!

                sierdzioS 離線
                sierdzioS 離線
                sierdzio
                Moderators
                寫於 最後由 編輯
                #6

                @qcoderpro said in QML Image: TLS initialization failed:

                @sierdzio

                But I've installed OpenSSL using Qt!

                But it's not a system-wide installation.

                You mean I can't load an image from the Internet on Windows!?

                You can. Just link OpenSSL to your project, or place OpenSSL DLLs close to the .exe.

                (Z(:^

                Q 1 條回覆 最後回覆
                0
                • sierdzioS sierdzio

                  @qcoderpro said in QML Image: TLS initialization failed:

                  @sierdzio

                  But I've installed OpenSSL using Qt!

                  But it's not a system-wide installation.

                  You mean I can't load an image from the Internet on Windows!?

                  You can. Just link OpenSSL to your project, or place OpenSSL DLLs close to the .exe.

                  Q 離線
                  Q 離線
                  qcoderpro
                  寫於 最後由 編輯
                  #7

                  @sierdzio

                  Just link OpenSSL to your project

                  How to do that on Windows?

                  1 條回覆 最後回覆
                  0
                  • sierdzioS 離線
                    sierdzioS 離線
                    sierdzio
                    Moderators
                    寫於 最後由 編輯
                    #8
                    • find where your OpenSSL installation is
                    • in your .pro file (I assume you're using qmake), add:
                    LIBS+=path/to/openssl/libs
                    INCLUDEPATH+=path/to/openssl/include
                    

                    (Z(:^

                    Q 1 條回覆 最後回覆
                    1
                    • sierdzioS sierdzio
                      • find where your OpenSSL installation is
                      • in your .pro file (I assume you're using qmake), add:
                      LIBS+=path/to/openssl/libs
                      INCLUDEPATH+=path/to/openssl/include
                      
                      Q 離線
                      Q 離線
                      qcoderpro
                      寫於 最後由 qcoderpro 編輯
                      #9

                      @sierdzio

                      I've installed both x64 and x86 versions of openssl but the kit I'm using to run the project is x64 so I add: C:\Qt\Tools\OpenSSL\Win_x64\lib

                      But I'm using CMake. Can I add these two lines just like the .pro file of qmake in it?

                      LIBS += C:\Qt\Tools\OpenSSL\Win_x64\lib   // (There's no 'libs' folder in the openssl directory)
                      INCLUDEPATH += C:\Qt\Tools\OpenSSL\Win_x64\include
                      
                      1 條回覆 最後回覆
                      0
                      • sierdzioS 離線
                        sierdzioS 離線
                        sierdzio
                        Moderators
                        寫於 最後由 編輯
                        #10

                        For cmake, you should use FindOpenSSL: https://cmake.org/cmake/help/latest/module/FindOpenSSL.html

                        (Z(:^

                        Q 1 條回覆 最後回覆
                        3
                        • sierdzioS sierdzio

                          For cmake, you should use FindOpenSSL: https://cmake.org/cmake/help/latest/module/FindOpenSSL.html

                          Q 離線
                          Q 離線
                          qcoderpro
                          寫於 最後由 qcoderpro 編輯
                          #11

                          @sierdzio

                          I added the following two lines in the .txt file and saved the project. No errors came up:

                          find_package(OpenSSL)
                          target_link_libraries(QML_5 PRIVATE OpenSSL::SSL)
                          

                          But still the project can't run successfully!

                          12f0f584-a4de-4aa9-8ffd-59e368f3b1de-image.png

                          1 條回覆 最後回覆
                          0
                          • SGaistS 離線
                            SGaistS 離線
                            SGaist
                            Lifetime Qt Champion
                            寫於 最後由 編輯
                            #12

                            Hi,

                            Which version of OpenSSL are you using ?

                            Interested in AI ? www.idiap.ch
                            Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                            Q 1 條回覆 最後回覆
                            0
                            • SGaistS SGaist

                              Hi,

                              Which version of OpenSSL are you using ?

                              Q 離線
                              Q 離線
                              qcoderpro
                              寫於 最後由 編輯
                              #13

                              @SGaist

                              I don't know! (How to know that!?)

                              But it's written in CMakeLists.txt:

                              cmake_minimum_required(VERSION 3.14)

                              1 條回覆 最後回覆
                              0
                              • SGaistS 離線
                                SGaistS 離線
                                SGaist
                                Lifetime Qt Champion
                                寫於 最後由 編輯
                                #14

                                That's the minimal cmake version required to build the project.

                                As for OpenSSL, the installer might tell you this.
                                The headers of the library.

                                Or use QSslSocket::sslLibraryVersionString.

                                Interested in AI ? www.idiap.ch
                                Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                                Q 1 條回覆 最後回覆
                                0
                                • SGaistS SGaist

                                  That's the minimal cmake version required to build the project.

                                  As for OpenSSL, the installer might tell you this.
                                  The headers of the library.

                                  Or use QSslSocket::sslLibraryVersionString.

                                  Q 離線
                                  Q 離線
                                  qcoderpro
                                  寫於 最後由 編輯
                                  #15

                                  @SGaist

                                  As for OpenSSL, the installer might tell you this.
                                  The headers of the library.

                                  Capture4.PNG

                                  Or use QSslSocket::sslLibraryVersionString.

                                  How to use it in my QML project?
                                  I used it this way but that doesn't work!

                                  Component.onCompleted: {
                                          console.log(QSslSocket::sslLibraryVersionString)
                                      }
                                  
                                  1 條回覆 最後回覆
                                  0
                                  • SGaistS 離線
                                    SGaistS 離線
                                    SGaist
                                    Lifetime Qt Champion
                                    寫於 最後由 編輯
                                    #16

                                    @qcoderpro said in QML Image: TLS initialization failed:

                                    QSslSocket::sslLibraryVersionString

                                    Use it in you main.cpp.

                                    Interested in AI ? www.idiap.ch
                                    Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                                    Q 1 條回覆 最後回覆
                                    1
                                    • SGaistS SGaist

                                      @qcoderpro said in QML Image: TLS initialization failed:

                                      QSslSocket::sslLibraryVersionString

                                      Use it in you main.cpp.

                                      Q 離線
                                      Q 離線
                                      qcoderpro
                                      寫於 最後由 qcoderpro 編輯
                                      #17

                                      @SGaist

                                      I included these two header files:

                                      #include <iostream>
                                      #include <QSslSocket>
                                      

                                      and this line in main.cpp:

                                      std::cout<< "The openSSL version is: " <<
                                                  QSslSocket::sslLibraryVersionString << '\n'
                                      

                                      In return I get this warning in the Issues window and nothing related to what I foresee in Application/Compile Output windows!

                                      warning: address of function 'QSslSocket::sslLibraryVersionString' will always evaluate to 'true'

                                      1 條回覆 最後回覆
                                      0
                                      • SGaistS 離線
                                        SGaistS 離線
                                        SGaist
                                        Lifetime Qt Champion
                                        寫於 最後由 編輯
                                        #18

                                        QSslSocket::sslLibraryVersionString is a static function that you have to call.

                                        Interested in AI ? www.idiap.ch
                                        Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                                        Q 1 條回覆 最後回覆
                                        1
                                        • SGaistS SGaist

                                          QSslSocket::sslLibraryVersionString is a static function that you have to call.

                                          Q 離線
                                          Q 離線
                                          qcoderpro
                                          寫於 最後由 編輯
                                          #19

                                          @SGaist

                                          Yes, I didn't notice the parentheses enough. Finally using: qInfo() << QSslSocket::sslLibraryVersionString(); I could see the result: "OpenSSL 1.1.1f 31 Mar 2020", which is very close to what the installer showed!

                                          1 條回覆 最後回覆
                                          0
                                          • SGaistS 離線
                                            SGaistS 離線
                                            SGaist
                                            Lifetime Qt Champion
                                            寫於 最後由 編輯
                                            #20

                                            Except it should be the j release. You should ensure that this is the one used by your application.

                                            Interested in AI ? www.idiap.ch
                                            Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                                            Q 1 條回覆 最後回覆
                                            0

                                            • 登入

                                            • Login or register to search.
                                            • 第一個貼文
                                              最後的貼文
                                            0
                                            • 版面
                                            • 最新
                                            • 標籤
                                            • 熱門
                                            • 使用者
                                            • 群組
                                            • 搜尋
                                            • Get Qt Extensions
                                            • Unsolved