Navigation

    Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Search
    • Unsolved
    1. Home
    2. Tags
    3. deletelater
    Log in to post

    • SOLVED QNetworkReply* ownership
      General and Desktop • network qnetworkreply qtnetwork deletelater • • mistralegna  

      5
      0
      Votes
      5
      Posts
      33
      Views

      AFAIK, if this does happen you likely have other bigger issues. The signal is not related to the success of the request.
    • SOLVED problem opening one instance of every Widget(form) and deleting it ...
      General and Desktop • qwidget qt5.6 release deletelater form • • Proton Phoenix  

      9
      0
      Votes
      9
      Posts
      157
      Views

      @JonB it works bro thank you problem fixed when i tried this before it doesn't open the window at all ... just flashing but now i understand why it's working Thank you <3
    • SOLVED In what thread would a QObject be deleted if it was moved to another QThread?
      General and Desktop • thread event loop deletelater • • LRDPRDX  

      2
      0
      Votes
      2
      Posts
      114
      Views

      @LRDPRDX said in In what thread would a QObject be deleted if it was moved to another QThread?: the dtor must be called and executed in the secondary thread not the main one. Am I right? Correct, that's what connect(thread, &QThread::finished, worker, &QObject::deleteLater); does and as you noted> No more events will be processed in the thread, except for deferred deletion events. Do the deleteLater will still picked up after the finished is emitted and the destructor will run in the secondary thread
    • SOLVED double free or corruption (out) when closing a QDialog with the WA_DeleteOnClose attribute set
      General and Desktop • qdialog deletelater • • LRDPRDX  

      20
      0
      Votes
      20
      Posts
      332
      Views

      @kshegunov Yes, ofc, I read that. For some reason I interpret the word "delete" (when it's not formatted :) ) as a general way to destroy an object. -_-
    • SOLVED Do I need to call deleteLater() function if QTreeView has widget ownership?
      General and Desktop • qtreeview qstandarditemmo deletelater removerow setindexwidget • • Yash001  

      5
      0
      Votes
      5
      Posts
      183
      Views

      @Yash001 When items are removed from a model the view will update to reflect the new state. Widgets you have added via setIndexWidget() which are no longer present will be deleted by Qt infrastructure without you needing to delete them or disconnect from signals.
    • UNSOLVED Delete all instances of an object?
      General and Desktop • qpushbutton memory leak deletelater object • • adamsmith  

      9
      0
      Votes
      9
      Posts
      794
      Views

      You need to add extra logic in your prog. Your problem seems very similar to the Copy/Cut/Paste logic. You don't know if the paste command is valid because you don't know if the user press copy command before that. Well, is up to you to register the states of this commands. So you need to implement the logic suitable to your case, for example, if the list of items is empty, obviously you cannot edit it, etc. About the interfaces (as others said), create them on the fly could be tricky and error prone. You can do it if only minor changes are to be made (hide/disable a few button/options) If the interfaces are very different, better way to create a unique persistent widget for each, and put them in a StackedWidget. Good luck :;)
    • UNSOLVED DeleteLater never deletes...
      General and Desktop • qwidget deletelater • • Dariusz  

      6
      0
      Votes
      6
      Posts
      1292
      Views

      You should really read the chapter about the parent/child relationship here: https://doc.qt.io/qt-5/qobject.html#details ".... The parent takes ownership of the object; i.e., it will automatically delete its children in its destructor" So if they are all children of your mWidget then they will get deleted when mWidget is destroyed.
    • UNSOLVED endRemoveRows() and QML ListView deleteLater() synchronization
      QML and Qt Quick • qml listview deletelater • • Zaraka  

      2
      0
      Votes
      2
      Posts
      477
      Views

      Had the same problem. Fixed it by not binding the object referenced by the role to a property and using the property but using the role name directly to acces the model item. Instead of property MyItem myItem: model.object text: myItem.foo try text: model.object.foo
    • SOLVED How to delete the objects from QMap?
      General and Desktop • qmap delete deletelater qdeleteall • • Yash001  

      5
      0
      Votes
      5
      Posts
      1542
      Views

      @mpergand Thank you for help.
    • SOLVED can I assign another object after using deleteLater(); funcation?
      General and Desktop • qfile delete deletelater • • Yash001  

      3
      0
      Votes
      3
      Posts
      364
      Views

      @koahnig thank you.
    • SOLVED Why QNetworkReply run-time crash on deleteLater() ?
      General and Desktop • crash qnetworkreply qtnetwork deletelater • • IMAN4K  

      10
      0
      Votes
      10
      Posts
      2707
      Views

      At long last! i decided to simply process reply in worker thread(Thanks @raven-worx ): using Header = QMap<QString, QString>; class HttpWorker : public QObject { Q_OBJECT public: struct HttpData { bool hasError = false; NetworkError error = NetworkError::NoError; QString errorString; QByteArray data; }; HttpWorker(QThread*, const QUrl&, const QUrlQuery&); ~HttpWorker(); void addHeaders(const Header&); enum Method { Post, Get }; void setMethod(Method m) { http_method = m; } Method method() const { return http_method; } private Q_SLOTS: void sendRequest(); private: QNetworkAccessManager manager; Header headers; QUrlQuery params; QUrl url; Method http_method = Post; private: void check(QNetworkReply*); void appendHeaders(QNetworkRequest*); Q_SIGNALS: void finished(HttpData); }; HttpWorker::HttpWorker(QThread* thread, const QUrl& _url, const QUrlQuery& _params) :url{ _url }, params{ _params } { qRegisterMetaType<HttpData>("HttpData"); moveToThread(thread); manager.moveToThread(thread); QObject::connect(thread, &QThread::started, this, &HttpWorker::sendRequest); QObject::connect(this, &HttpWorker::finished, thread, &QThread::quit); QObject::connect(thread, &QThread::finished, thread, &QThread::deleteLater); QObject::connect(thread, &QThread::finished, this, &HttpWorker::deleteLater); QObject::connect(&manager, &QNetworkAccessManager::finished, this, &HttpWorker::check); } HttpWorker::~HttpWorker() { } void HttpWorker::addHeaders(const Header& _headers) { headers = std::move(_headers); } void HttpWorker::appendHeaders(QNetworkRequest* req) { if (!req) return; QMapIterator<QString, QString> iterator(headers); while (iterator.hasNext()) { iterator.next(); req->setRawHeader(QByteArray::fromStdString(iterator.key().toStdString()), QByteArray::fromStdString(iterator.value().toStdString())); } } void HttpWorker::sendRequest() { const auto content_h = QStringLiteral("application/x-www-form-urlencoded"); if (method() == Post) { QNetworkRequest req(url); req.setHeader(QNetworkRequest::ContentTypeHeader, content_h); if (!headers.isEmpty()) appendHeaders(&req); const auto data = params.isEmpty() ? url.toEncoded() : params.toString(QUrl::FullyEncoded).toUtf8(); manager.post(req, data); } else { url.setQuery(params); QNetworkRequest req(url); req.setHeader(QNetworkRequest::ContentTypeHeader, content_h); manager.get(req); } } void HttpWorker::check(QNetworkReply* reply) { HttpData data; if (reply->error()) { data.hasError = true; data.error = reply->error(); data.errorString = reply->errorString(); } else { data.data = std::move(reply->readAll()); } emit finished(std::move(data)); reply->deleteLater(); }
    • SOLVED Crash in QGraphicsScene::event when removing and deleting items that use SceneEventFilters
      General and Desktop • qgraphicsscene eventfilter deletelater removeitem • • JEllery  

      6
      0
      Votes
      6
      Posts
      4503
      Views

      @JEllery Thanks so much for solving this. It seems to solve my deletion-crash issue as well. :)