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. can I assign another object after using deleteLater(); funcation?

can I assign another object after using deleteLater(); funcation?

Scheduled Pinned Locked Moved Solved General and Desktop
deletelaterqfiledelete
3 Posts 2 Posters 704 Views
  • 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.
  • Y Offline
    Y Offline
    Yash001
    wrote on 12 Oct 2018, 17:48 last edited by Yash001 10 Dec 2018, 17:49
    #1

    is it fine? if i will assign new object to currentDataFile pointer. once I call deleteLater() for old object with help of currentDataFile.

    private member of class

    QFile* currentDataFile;
    QString currentDataFilePath;
    

    method of class

    void DataHandle::createNewDataFile(uint16_t nodeNum, const ExperimentSummaryInfo_t &expInfo) {
    	
    	if (!currentDataFile) {
    		
    		createNewFilePath(nodeNum, expInfo);
    		currentDataFile->flush();
    		currentDataFile->close();
    		currentDataFile->deleteLater();   
    	}
    
    	currentDataFile = new QFile(currentDataFilePath);
    	
    	if (!currentDataFile->open(QIODevice::WriteOnly)) {
    		currentDataFile->close();
    		currentDataFile->deleteLater();
    	}
    
    	return;
    }
    
    K 1 Reply Last reply 12 Oct 2018, 18:01
    0
    • Y Yash001
      12 Oct 2018, 17:48

      is it fine? if i will assign new object to currentDataFile pointer. once I call deleteLater() for old object with help of currentDataFile.

      private member of class

      QFile* currentDataFile;
      QString currentDataFilePath;
      

      method of class

      void DataHandle::createNewDataFile(uint16_t nodeNum, const ExperimentSummaryInfo_t &expInfo) {
      	
      	if (!currentDataFile) {
      		
      		createNewFilePath(nodeNum, expInfo);
      		currentDataFile->flush();
      		currentDataFile->close();
      		currentDataFile->deleteLater();   
      	}
      
      	currentDataFile = new QFile(currentDataFilePath);
      	
      	if (!currentDataFile->open(QIODevice::WriteOnly)) {
      		currentDataFile->close();
      		currentDataFile->deleteLater();
      	}
      
      	return;
      }
      
      K Offline
      K Offline
      koahnig
      wrote on 12 Oct 2018, 18:01 last edited by
      #2

      @Yash001

      Yes. deleteLater is some sort of a member function of the object. You use only the pointer to start it.

      Vote the answer(s) that helped you to solve your issue(s)

      1 Reply Last reply
      5
      • Y Offline
        Y Offline
        Yash001
        wrote on 12 Oct 2018, 18:11 last edited by
        #3

        @koahnig thank you.

        1 Reply Last reply
        0

        3/3

        12 Oct 2018, 18:11

        • Login

        • Login or register to search.
        3 out of 3
        • First post
          3/3
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved