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. Display LGPL and GPL content to users
QtWS25 Last Chance

Display LGPL and GPL content to users

Scheduled Pinned Locked Moved Solved General and Desktop
9 Posts 2 Posters 2.4k 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.
  • C Offline
    C Offline
    cobaltsixty
    wrote on last edited by
    #1

    Hi all :-)

    My application is close to deployment now. Since I use the LGPL licence of the Qt lib, one of the requirements is to give a copy of both GPL/LGPL licences to users. I want these licence files to be embedded within the app, not as side text files. As a consequence, I include two text files as declared resources in a .qrc file (COPYING.txt and COPYING.LESSER.txt). My GUI has two buttons appearing at the beginning. If the user clicks on it, I want to show the content of the files. Two options:

    1. Load files from the resources and use QDesktopServices::openUrl(). This seems to be the easiest solution because the files would show in the default text editor of the OS (WIN). As far as I understood from my readings, this is not possible because the resource files are not in the arborescence of the OS. Do you confirm ? Any workaround ? (I'd like to avoid writing a temp file)
    2. Use a textstream a feed a QMessage or a QTextEditor with this. The problem is I have to use readLine() in a while loop. How to feed the widgets with such streams ?

    By advance, thanks a lot for your help.

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      1. Without copying the file to a temporary file you can't.
      2. Why not read the complete file in one with QFile and set its content to e.g. a QLabel ?

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      C 3 Replies Last reply
      1
      • SGaistS SGaist

        Hi,

        1. Without copying the file to a temporary file you can't.
        2. Why not read the complete file in one with QFile and set its content to e.g. a QLabel ?
        C Offline
        C Offline
        cobaltsixty
        wrote on last edited by
        #3

        @SGaist Hi, and thanks for your answers.

        1. OK, cristal clear confirmation of what I expected
        2. Will give it a try and let you know. I didn't realize that QFile could be used directly.

        Stay tuned for final results if interested.

        1 Reply Last reply
        0
        • SGaistS SGaist

          Hi,

          1. Without copying the file to a temporary file you can't.
          2. Why not read the complete file in one with QFile and set its content to e.g. a QLabel ?
          C Offline
          C Offline
          cobaltsixty
          wrote on last edited by cobaltsixty
          #4

          @SGaist
          Test 2) but, fore some reason I don't understand, the textedit disappears immediately ???

          void disclaimerPage::showGPL()
          {
              QTextEdit textWindow;
              textWindow.setGeometry(100,100,200,400);
              textWindow.setReadOnly(true);
          
              QString text;
          
              QResource common("://licences/COPYING.txt");
              QFile commonFile(common.absoluteFilePath());
          
              if(commonFile.open(QFile::ReadOnly | QFile::Text))
                  {
                       text = commonFile.readAll();
                       commonFile.close();
                  }
              else text = "Cannot open file !";
          
              textWindow.setText(text);
              textWindow.show();
          }
          

          This code is a slot of a qpushbutton within a qwizard page... I think there's something I don't understand with parent and child windows :=(

          Any idea would be appreciated

          1 Reply Last reply
          0
          • SGaistS SGaist

            Hi,

            1. Without copying the file to a temporary file you can't.
            2. Why not read the complete file in one with QFile and set its content to e.g. a QLabel ?
            C Offline
            C Offline
            cobaltsixty
            wrote on last edited by
            #5

            @SGaist Problem solved, I missed the basics. Many thanks

            void disclaimerPage::showGPL()
            {
                QTextEdit *textBox = new QTextEdit();
                textBox->setGeometry(100,100,200,400);
                textBox->setReadOnly(true);
            
                QString text;
            
                QResource common("://licences/COPYING.txt");
                QFile commonFile(common.absoluteFilePath());
            
                if(commonFile.open(QFile::ReadOnly | QFile::Text))
                    {
                         text = commonFile.readAll();
                         commonFile.close();
                    }
                else text = "Impossible d'ouvrir le fichier !";
            
                textBox->setText(text);
                textBox->show();
            }
            
            1 Reply Last reply
            0
            • SGaistS Offline
              SGaistS Offline
              SGaist
              Lifetime Qt Champion
              wrote on last edited by
              #6

              Except now you have a memory leak.

              You should add textBox->setAttribute(Qt::WA_DeleteOnClose);to ensure it gets destroyed properly when the users closes it.

              The other possibility is rollback to your original implementation but call exec in place of show. That will block your application while the user reads the file(s)

              Interested in AI ? www.idiap.ch
              Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

              C 2 Replies Last reply
              1
              • SGaistS SGaist

                Except now you have a memory leak.

                You should add textBox->setAttribute(Qt::WA_DeleteOnClose);to ensure it gets destroyed properly when the users closes it.

                The other possibility is rollback to your original implementation but call exec in place of show. That will block your application while the user reads the file(s)

                C Offline
                C Offline
                cobaltsixty
                wrote on last edited by
                #7

                @SGaist one more good point. Thx.

                1 Reply Last reply
                0
                • SGaistS SGaist

                  Except now you have a memory leak.

                  You should add textBox->setAttribute(Qt::WA_DeleteOnClose);to ensure it gets destroyed properly when the users closes it.

                  The other possibility is rollback to your original implementation but call exec in place of show. That will block your application while the user reads the file(s)

                  C Offline
                  C Offline
                  cobaltsixty
                  wrote on last edited by cobaltsixty
                  #8

                  @SGaist one more problem, the file doesn't display properly (utf-8 encoding, french language). Since readAll() returns a QByteArray, do you know a way to solve the issue ???

                  1 Reply Last reply
                  0
                  • SGaistS Offline
                    SGaistS Offline
                    SGaist
                    Lifetime Qt Champion
                    wrote on last edited by
                    #9

                    You can use the QString::fromUtf8

                    Interested in AI ? www.idiap.ch
                    Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                    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