Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

How to build Qt (qtwebview module) from Sources



  • Hello All,

    I'm developing an application for iOS 11, and I'm using qtwebview (aka WKWebView) module for UI. My application should play videos sometimes, but with the newest iOS 11 updates, User has to make at least one UI interaction before the video can be played with sound. So I found a solution for that: Change WKWebViewConfiguration and pass it to WKWebView.

    file that I modified: ~/Qt/5.11.0/Src/qtwebview/src/plugins/darwin/qdarwinwebview.mm

    QDarwinWebViewPrivate::QDarwinWebViewPrivate(QObject *p)
        : QAbstractWebView(p)
        , wkWebView(nil)
    #ifdef Q_OS_IOS
        , m_recognizer(0)
    #endif
    {
        CGRect frame = CGRectMake(0.0, 0.0, 400, 400);
    
    //---Allow-Video-Playback-Programmatically---
        WKWebViewConfiguration* wkConfiguration = [[WKWebViewConfiguration alloc] init]; 
        [wkConfiguration setAllowsInlineMediaPlayback: YES]; 
        [wkConfiguration setMediaTypesRequiringUserActionForPlayback:WKAudiovisualMediaTypeNone];
     wkWebView = [[WKWebView alloc] initWithFrame:frame configuration:wkConfiguration];
    //---^^^--End--^^^---
    
    //    wkWebView = [[WKWebView alloc] initWithFrame:frame];
       
    
        wkWebView.navigationDelegate = [[QtWKWebViewDelegate alloc] initWithQAbstractWebView:this];
        [wkWebView addObserver:wkWebView.navigationDelegate forKeyPath:@"estimatedProgress"
                       options:NSKeyValueObservingOptions(NSKeyValueObservingOptionNew)
                       context:nil];
    
    #ifdef Q_OS_IOS
        m_recognizer = [[QIOSNativeViewSelectedRecognizer alloc] initWithQWindowControllerItem:this];
        [wkWebView addGestureRecognizer:m_recognizer];
    #endif
    }
    

    After that I'm running

    ~/Qt/5.11.0/Src/configure -prefix ./5.11.0-modified -debug-and-release -nomake tests -nomake examples -xplatform macx-ios-clang -commercial -confirm-license
    ...
    make -j4
    

    And at some point of compiling process I'm receiving errors.

    I would appreciate if someone tell me what I'm doing wrong? I'm compiling Qt from sources for the first time.


  • Lifetime Qt Champion

    Hi and welcome to devnet,

    What exact error are you having ?



  • Thanks.
    I'm getting an error like this:

    /Users/mitem/WorkSpace/GitHub/qt5/qtbase/src/platformsupport/fontdatabases/mac/qfontengine_coretext.mm:827:20: error: 
          qualified reference to 'QFixed' is a constructor name rather than a type in this context
        return QFixed::QFixed(int(CTFontGetUnitsPerEm(ctfont)));
                       ^
    1 error generated.
    make[4]: *** [.obj/qfontengine_coretext.o] Error 1
    make[3]: *** [sub-fontdatabases-make_first] Error 2
    make[2]: *** [sub-platformsupport-make_first] Error 2
    make[1]: *** [sub-src-make_first] Error 2
    make: *** [module-qtbase-make_first] Error 2
    

    Also I forgot to mention that I'm working on macOS 10.13 and I have Qt5.11 installed from online installer.



  • I just found a fix for that issue:
    https://wiki.qt.io/Qt_5.9.5_Known_Issues

    I'm not sure why the bug from Qt5.9.5 is still in Qt5.11.
    Anyway, I'm still waiting when the build finishes.


Log in to reply