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. QFile Problem
Forum Updated to NodeBB v4.3 + New Features

QFile Problem

Scheduled Pinned Locked Moved Unsolved General and Desktop
16 Posts 6 Posters 2.7k 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.
  • L Offline
    L Offline
    LainOnTheWired
    wrote on last edited by
    #5

    Yes it is included.

    1 Reply Last reply
    0
    • VRoninV Offline
      VRoninV Offline
      VRonin
      wrote on last edited by
      #6

      very strange... in any case you can replace

      if (!file.open(QIODevice::WriteOnly | QIODevice::Text))
              return;
      

      with

      if (!file.open(QIODevice::WriteOnly))
              return;
      file.setTextModeEnabled(true);
      

      "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
      ~Napoleon Bonaparte

      On a crusade to banish setIndexWidget() from the holy land of Qt

      JonBJ 1 Reply Last reply
      0
      • VRoninV VRonin

        very strange... in any case you can replace

        if (!file.open(QIODevice::WriteOnly | QIODevice::Text))
                return;
        

        with

        if (!file.open(QIODevice::WriteOnly))
                return;
        file.setTextModeEnabled(true);
        
        JonBJ Online
        JonBJ Online
        JonB
        wrote on last edited by
        #7

        @VRonin
        I'd be worried if I got his error message! I don't do C++/includes, but does he need to also #include <QIODevice> for the flag definitions?

        VRoninV 1 Reply Last reply
        1
        • L Offline
          L Offline
          LainOnTheWired
          wrote on last edited by LainOnTheWired
          #8

          Yes thats it with include<QIODevice> it works thanks so much :) and you need to include #include <qtextstream.h> for the stream too.

          JKSHJ 1 Reply Last reply
          0
          • L LainOnTheWired

            Yes thats it with include<QIODevice> it works thanks so much :) and you need to include #include <qtextstream.h> for the stream too.

            JKSHJ Online
            JKSHJ Online
            JKSH
            Moderators
            wrote on last edited by
            #9

            @LainOnTheWired said in QFile Problem:

            Yes thats it with include<QIODevice> it works thanks so much :) and you need to include #include <qtextstream.h> for the stream too.

            That's very odd. The QFile header should already contain #include <QIODevice>...

            Has the QFile header been modified?

            Qt Doc Search for browsers: forum.qt.io/topic/35616/web-browser-extension-for-improved-doc-searches

            1 Reply Last reply
            4
            • JonBJ JonB

              @VRonin
              I'd be worried if I got his error message! I don't do C++/includes, but does he need to also #include <QIODevice> for the flag definitions?

              VRoninV Offline
              VRoninV Offline
              VRonin
              wrote on last edited by
              #10

              @JonB said in QFile Problem:

              I'd be worried if I got his error message!

              I wouldn't. It just cannot find the operator|() that is defined as part of specialising QFlags. Not a big deal

              "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
              ~Napoleon Bonaparte

              On a crusade to banish setIndexWidget() from the holy land of Qt

              JonBJ 1 Reply Last reply
              2
              • VRoninV VRonin

                @JonB said in QFile Problem:

                I'd be worried if I got his error message!

                I wouldn't. It just cannot find the operator|() that is defined as part of specialising QFlags. Not a big deal

                JonBJ Online
                JonBJ Online
                JonB
                wrote on last edited by
                #11

                @VRonin
                That's precisely what I meant! Perhaps "worried" was too strong a word :) The error message suggested to me that the QFlags were not working correctly with the | operator, hence my guess about not having the correct #include. I intended to suggest that the OP should pursue why this appeared to be the case.

                1 Reply Last reply
                0
                • L Offline
                  L Offline
                  LainOnTheWired
                  wrote on last edited by LainOnTheWired
                  #12

                  It is the fault of KDevelop, if i have only the QFile include it puts this error message but if i compile the program it works correctly. The error message is wrong. Very strange and no i have not modified the header file.

                  JonBJ 1 Reply Last reply
                  0
                  • L LainOnTheWired

                    It is the fault of KDevelop, if i have only the QFile include it puts this error message but if i compile the program it works correctly. The error message is wrong. Very strange and no i have not modified the header file.

                    JonBJ Online
                    JonBJ Online
                    JonB
                    wrote on last edited by
                    #13

                    @LainOnTheWired

                    The error message is wrong.

                    Up to you, but the compiler error/warning message cannot be "wrong". If it warns it means what it says in terms of not having the definition, compilers don't invent error messages. It may work at runtime if it's only a warning and the semantics actually allow an int operator|() to work in this case, which it probably does.

                    Likely perhaps: if you have other #includes (e.g. from "KDevelop") prior (or possibly post) to your #include <QFile> that might affect definitions/behaviour and cause your issue....

                    jsulmJ 1 Reply Last reply
                    0
                    • JonBJ JonB

                      @LainOnTheWired

                      The error message is wrong.

                      Up to you, but the compiler error/warning message cannot be "wrong". If it warns it means what it says in terms of not having the definition, compilers don't invent error messages. It may work at runtime if it's only a warning and the semantics actually allow an int operator|() to work in this case, which it probably does.

                      Likely perhaps: if you have other #includes (e.g. from "KDevelop") prior (or possibly post) to your #include <QFile> that might affect definitions/behaviour and cause your issue....

                      jsulmJ Online
                      jsulmJ Online
                      jsulm
                      Lifetime Qt Champion
                      wrote on last edited by
                      #14

                      @JonB I think the error is not coming from the compiler but from the Clang Code Model which is known for producing many false positives.
                      @LainOnTheWired You can try to disable Clang Code Model

                      https://forum.qt.io/topic/113070/qt-code-of-conduct

                      JonBJ 1 Reply Last reply
                      1
                      • jsulmJ jsulm

                        @JonB I think the error is not coming from the compiler but from the Clang Code Model which is known for producing many false positives.
                        @LainOnTheWired You can try to disable Clang Code Model

                        JonBJ Online
                        JonBJ Online
                        JonB
                        wrote on last edited by
                        #15

                        @jsulm
                        Ohhh, I don't know anything about CLang or that the OP is using that, apologies then if my comment was misleading.

                        jsulmJ 1 Reply Last reply
                        0
                        • JonBJ JonB

                          @jsulm
                          Ohhh, I don't know anything about CLang or that the OP is using that, apologies then if my comment was misleading.

                          jsulmJ Online
                          jsulmJ Online
                          jsulm
                          Lifetime Qt Champion
                          wrote on last edited by
                          #16

                          @JonB No problem! Actually the OP was not clear when saying "it puts this error message" - this can be the compiler or the code model.

                          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