Results 1 to 5 of 5

Thread: QQuickView redraw: setSource() 2nd time leads to Qt-Assert

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jan 2012
    Location
    Dortmund, Germany
    Posts
    159
    Thanks
    69
    Thanked 10 Times in 8 Posts
    Qt products
    Qt4
    Platforms
    Windows Android

    Default QQuickView redraw: setSource() 2nd time leads to Qt-Assert

    Hi,
    I have a QuickView interface where the user can edit data.

    A reset button (inside the interface) sets the underlying data (an interface object that is set as a context property) back to model data by calling a slot in that very interface object. Unfortunately, the qml content is not being visibly updated.

    I'd be happy with just rebuilding the QML content from scratch by setting the QQuickview's source anew after resetting my data, like here:

    Qt Code:
    1. void ControllerClass::redrawIncEditView()
    2. {
    3. Q_ASSERT(m_quickView);
    4. auto url = m_quickView->source();
    5. // m_quickView->hide();
    6. m_quickView->setSource(url); //<<<<< HERE we have the assert you see below
    7. // m_quickView->show();
    8. }
    To copy to clipboard, switch view to plain text mode 

    But calling this leads to a crash in Qt:
    ASSERT: "context() && engine()" in file qml\qqmlboundsignal.cpp, line 183
    I have no idea why the crash occurs. Ive seen very similar / same error messages on Google, but in quite different contexts, as far as I can see.

    I've also tried calling the following methods of QQuickView, but they don't show any effect (probably they just cover the graphical aspects):
    Qt Code:
    1. m_quickView->update();
    2. m_quickView->requestUpdate();
    3. m_quickView->renderTarget();
    To copy to clipboard, switch view to plain text mode 

    Interesting update:

    The above approach works when started by a single shot timer. Therefore I have to subclass QQuickView, adding a "redraw"-method that takes no argument (to make it usable with QTimer::singleShot):
    Qt Code:
    1. class MyQQuickView: public QQuickView {
    2. Q_OBJECT
    3. public slots:
    4. void redraw() { this->setSource(this->source()); }
    5. };
    To copy to clipboard, switch view to plain text mode 
    and call that in this way:
    Qt Code:
    1. void ControllerClass::redrawIncEditView()
    2. {
    3. Q_ASSERT(m_quickView);
    4. QTimer::singleShot(1,m_quickView,SLOT(redraw()));
    5. }
    To copy to clipboard, switch view to plain text mode 

    Any idea about what is behind the crash? Is it a threading problem?
    Are there better / more elegant ways to force a QML redraw?
    Is that hack somewhat safe in the first place? I can use it with 1 ms here - but could this be different on a phone?
    Last edited by sedi; 6th August 2016 at 00:24.

Similar Threads

  1. How to set QWebEngineView on QQuickView
    By ejoshva in forum Newbie
    Replies: 112
    Last Post: 11th July 2015, 09:07
  2. QQuickView or QQmlApplicationEngine or QQuickWidget
    By ustulation in forum Qt Quick
    Replies: 0
    Last Post: 18th January 2015, 13:16
  3. Repaint a QML Scene (QQuickView)
    By alizadeh91 in forum Qt Programming
    Replies: 0
    Last Post: 23rd July 2013, 09:54
  4. textBrowser->setSource() end-of-line
    By gib in forum Qt Programming
    Replies: 8
    Last Post: 24th April 2011, 00:05
  5. QTextBrowser setSource (Qt 4.2.2)
    By manojmka in forum Qt Programming
    Replies: 0
    Last Post: 10th January 2008, 07:00

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.