Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. How to store .wav file(media file) in sqllite databse
Forum Updated to NodeBB v4.3 + New Features

How to store .wav file(media file) in sqllite databse

Scheduled Pinned Locked Moved QML and Qt Quick
5 Posts 2 Posters 1.4k Views 1 Watching
  • 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.
  • P Offline
    P Offline
    prabhatjha
    wrote on last edited by
    #1

    hey i have lots of .wav file(media) file and i want to store these file in sqllite database but i have no more idea about sqllite database .please help me how to store and retrive these data from sqllite.

    1 Reply Last reply
    0
    • D Offline
      D Offline
      DBoosalis
      wrote on last edited by
      #2

      I would suggest as a BLOB.

      To Retrieve It:
      @QByteArray ba1 = query.value(fieldNum).toByteArray();@

      To Set It:
      @QByteArray ba;
      QDataStream ds(&ba,QIODevice::WriteOnly);
      ds << wavFileContents;
      ...
      bstatus = query.prepare("INSERT INTO musicTable (id,name,media) " "VALUES (NULL, :name, :media)");
      query.bindValue(":name",fileName);
      query.bindValue(":media",ba);
      bstatus = query.exec();
      @

      1 Reply Last reply
      0
      • P Offline
        P Offline
        prabhatjha
        wrote on last edited by
        #3

        Thanks a lot DBoosalis ....please tell me what will be in the place of wavFileContents and how to use bstatus....actually i have no more idea about sqlite ....so please tell me step by step if its possible for u ...thanks in advance.

        1 Reply Last reply
        0
        • P Offline
          P Offline
          prabhatjha
          wrote on last edited by
          #4

          Hey Dboosalis tahnks, my problem has been solved .I can store bytearray in database and i can alsor retrive the bytearray(ba1) but i do not know how to get original file from these byte array . i can get image from these code
          @
          QSqlQuery query("SELECT Description,Signal FROM wav");
          query.next();
          QByteArray array = query.value(1).toByteArray();
          qDebug()<<array.length();

          QPixmap pixmap = QPixmap();
          pixmap.loadFromData(array);
          
          QPushButton *button = new QPushButton ();
          QIcon ButtonIcon(pixmap);
          
          button->setIcon(ButtonIcon);
          button->setIconSize(pixmap.rect().size());
          button->show();
          

          @

          but in case of .wav file how i will get original .wav file .

          [edit : please add @ tags around your code, Eddy]

          1 Reply Last reply
          0
          • D Offline
            D Offline
            DBoosalis
            wrote on last edited by
            #5

            I am no expert on wav files. Perhaps you should first try to write the QByteArray to a file with QFile::write(QByteArray) and then play it as you would normally.

            1 Reply Last reply
            0

            • Login

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