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. Problem with QtCreator application <MediaPlayer> with list of videos through databases

Problem with QtCreator application <MediaPlayer> with list of videos through databases

Scheduled Pinned Locked Moved Solved General and Desktop
media playererrordatabasehelpundefined
8 Posts 2 Posters 2.8k 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.
  • Q Offline
    Q Offline
    Qinyx
    wrote on 6 Jun 2016, 08:37 last edited by
    #1

    Hi,
    i have a little problem with my Qt application. In my function MediaPlayer, i´ve tried to create list of videos through QSqlDatabases, as i´ve gone further, the more i ruined it .. I can repair it to function state, but i really need that list. I have no idea where is problem, maybe it is because i am new in programing. Sorry for that.

    If there is someone who can tell me how to complete my application, or how to solve this error. It would be really great.

    Here is my code:
    https://mega.nz/#F!mYhURDAC!HyPVie-6oU7nZPJH-CwcGg

    Thanks for all advices

    Regards Qinyx

    PS: Sorry for mistakes, i am not from english speaking country, i am from Czech Republic :)

    1 Reply Last reply
    0
    • M Offline
      M Offline
      mrjj
      Lifetime Qt Champion
      wrote on 6 Jun 2016, 08:51 last edited by
      #2

      Hi and welcome :)
      You dont seem to open database at all or read from it.

      So where IS this DB file ?

      You must supply more details for us to help.

      If its the "cannot not open SQL driver" error, then just search the forum.
      tons of those for all platforms. :)

      1 Reply Last reply
      1
      • Q Offline
        Q Offline
        Qinyx
        wrote on 6 Jun 2016, 09:05 last edited by
        #3

        Yeah, i know that database was not open at all, because of these errors, that i am not able to solve.

        Screenshot: https://ctrlv.cz/gkj9

        Normaly in any other application .db file is created in built_** file, but in this case it was not created. I tried to delete all lines that includes something connected with databases, to get clear MediaPlayer, and then tried to do it again. Unfortunatelly no result.

        I am able to send you clear MediaPlayer, if you want. And if you are willing to rewrite/modify it to case, where i can easily add list/database connected with this media player. I would be really greatful.

        Regards Qinyx

        1 Reply Last reply
        0
        • M Offline
          M Offline
          mrjj
          Lifetime Qt Champion
          wrote on 6 Jun 2016, 09:14 last edited by mrjj 6 Jun 2016, 09:14
          #4

          Hi
          Its still not very clear what you want.
          Do you want to STORE list in data base or to read a preexisting DB?

          Here is sample that creates a DB

          bool createConnection() {
          QSqlDatabase db = QSqlDatabase::addDatabase("QSQLITE");
          db.setDatabaseName(":memory:");
          if (!db.open()) {
          QMessageBox::critical(0, qApp->tr("Cannot open database"), "Click Cancel to exit.", QMessageBox::Cancel);
          return false; }

          QSqlQuery query;
          qDebug() << "table:" << query.exec("create table person (id int primary key, "
          "firstname varchar(20), lastname varchar(20), num int )");
          query.exec("insert into person values(101, 'Dennis', 'Young','1')");
          query.exec("insert into person values(102, 'Christine', 'Holand','2')");
          query.exec("insert into person values(103, 'Lars junior', 'Gordon','4')");
          query.exec("insert into person values(104, 'Roberto', 'Robitaille','5')");
          query.exec("insert into person values(105, 'Maria', 'Papadopoulos','3')");
          return true;
          }

          and you call it like this

          createConnection();
          
            QSqlQuery query;
            int ok = query.prepare("SELECT * from person ");
            query.exec();
          
            while (query.next()) {
              QString name = query.value(1).toString(); // col 1 = name
              qDebug() << ">" << name;
            }
          
          1 Reply Last reply
          2
          • Q Offline
            Q Offline
            Qinyx
            wrote on 6 Jun 2016, 09:19 last edited by
            #5

            Well, what i want is really easy. I have media player, and when i will start any video, then it will add to list of played videos, and then append it into TextBrowser. Something like history. I know ho to create simple database without these connections, but i can not solve this problem i´ve got.

            I know, i am annoying, but i need to learn it somehow. Sorry for that :P

            Regards Qinyx

            M 1 Reply Last reply 6 Jun 2016, 09:33
            0
            • Q Qinyx
              6 Jun 2016, 09:19

              Well, what i want is really easy. I have media player, and when i will start any video, then it will add to list of played videos, and then append it into TextBrowser. Something like history. I know ho to create simple database without these connections, but i can not solve this problem i´ve got.

              I know, i am annoying, but i need to learn it somehow. Sorry for that :P

              Regards Qinyx

              M Offline
              M Offline
              mrjj
              Lifetime Qt Champion
              wrote on 6 Jun 2016, 09:33 last edited by
              #6

              @Qinyx
              So you can open database etc. ?

              So what is your actual true problem ?

              and no, you are not annoying but its unclear which part that is not working for you.
              The sample just makes the db in memory but easy to make it save to disk.

              I assume , you want is save history to DB and then on next start
              open db and read in the history ?

              1 Reply Last reply
              1
              • Q Offline
                Q Offline
                Qinyx
                wrote on 8 Jun 2016, 10:00 last edited by
                #7

                Hi,
                I am sorry for late replying. I´ve used your advices, and it is finally working :)

                For comparasing here is my final code.

                CODE: https://mega.nz/#F!mYhURDAC!HyPVie-6oU7nZPJH-CwcGg

                Thank you very much.

                Regards Qinyx

                M 1 Reply Last reply 8 Jun 2016, 10:12
                1
                • Q Qinyx
                  8 Jun 2016, 10:00

                  Hi,
                  I am sorry for late replying. I´ve used your advices, and it is finally working :)

                  For comparasing here is my final code.

                  CODE: https://mega.nz/#F!mYhURDAC!HyPVie-6oU7nZPJH-CwcGg

                  Thank you very much.

                  Regards Qinyx

                  M Offline
                  M Offline
                  mrjj
                  Lifetime Qt Champion
                  wrote on 8 Jun 2016, 10:12 last edited by
                  #8

                  @Qinyx
                  Good work.

                  1 Reply Last reply
                  0

                  1/8

                  6 Jun 2016, 08:37

                  • Login

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