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. The mystery of MouseMoveEvent of frameless QMainWindow
Forum Updated to NodeBB v4.3 + New Features

The mystery of MouseMoveEvent of frameless QMainWindow

Scheduled Pinned Locked Moved Solved General and Desktop
15 Posts 6 Posters 2.8k 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.
  • G Garrett

    @Faruq I think JonB is saying to look at your if statements again. You are assigning isMouseDown to be true, not checking if it is true. If you are checking if something is equal to some other value, you need to use the double equal sign "==" not the single equal sign "=".

    F Offline
    F Offline
    Faruq
    wrote on last edited by
    #6

    @Garrett Hi, thank you all. It only took me a few second to instantly know what goes wrong when I read Garrett post. Really appreciate it, Garrett :)

    JonBJ 1 Reply Last reply
    0
    • F Faruq

      @Garrett Hi, thank you all. It only took me a few second to instantly know what goes wrong when I read Garrett post. Really appreciate it, Garrett :)

      JonBJ Offline
      JonBJ Offline
      JonB
      wrote on last edited by
      #7

      @Faruq
      To help you: nearly all compilers I know would warn you on a line like:

      if(isMouseDown=true){
      

      about what you are likely to be doing wrong here.

      If your compiler did warn you, don't ignore warnings! If it did not, you should now ensure your IDE (QT Creator?) has all/most warnings switched on, e.g. if you're using gcc it's the -Wall command-line flag, there will be equivalent for others. I strongly recommend you sort this out going forward...

      J.HilkJ 1 Reply Last reply
      0
      • JonBJ JonB

        @Faruq
        To help you: nearly all compilers I know would warn you on a line like:

        if(isMouseDown=true){
        

        about what you are likely to be doing wrong here.

        If your compiler did warn you, don't ignore warnings! If it did not, you should now ensure your IDE (QT Creator?) has all/most warnings switched on, e.g. if you're using gcc it's the -Wall command-line flag, there will be equivalent for others. I strongly recommend you sort this out going forward...

        J.HilkJ Offline
        J.HilkJ Offline
        J.Hilk
        Moderators
        wrote on last edited by
        #8

        @JonB said in The mystery of MouseMoveEvent of frameless QMainWindow:

        @Faruq
        To help you: nearly all compilers I know would warn you on a line like:

        if(isMouseDown=true){
        

        about what you are likely to be doing wrong here.

        If your compiler did warn you, don't ignore warnings! If it did not, you should now ensure your IDE (QT Creator?) has all/most warnings switched on, e.g. if you're using gcc it's the -Wall command-line flag, there will be equivalent for others. I strongly recommend you sort this out going forward...

        Well if the op uses MSVC compiler than he will have no warning x)


        Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


        Q: What's that?
        A: It's blue light.
        Q: What does it do?
        A: It turns blue.

        JonBJ 1 Reply Last reply
        0
        • J.HilkJ J.Hilk

          @JonB said in The mystery of MouseMoveEvent of frameless QMainWindow:

          @Faruq
          To help you: nearly all compilers I know would warn you on a line like:

          if(isMouseDown=true){
          

          about what you are likely to be doing wrong here.

          If your compiler did warn you, don't ignore warnings! If it did not, you should now ensure your IDE (QT Creator?) has all/most warnings switched on, e.g. if you're using gcc it's the -Wall command-line flag, there will be equivalent for others. I strongly recommend you sort this out going forward...

          Well if the op uses MSVC compiler than he will have no warning x)

          JonBJ Offline
          JonBJ Offline
          JonB
          wrote on last edited by JonB
          #9

          @J.Hilk
          I have been using Visual Studio (outside of Qt) for, umm, 20 years, and I'm sure there must be a similar warning for "possibly unintended assignment inside condition", isn't there...??

          I Googled across, say, http://www.learncpp.com/cpp-programming/eight-c-programming-mistakes-the-compiler-wont-catch/

          Running a modern compiler at the highest warning level will cause it to issue a warning when an assignment is used in a conditional statement, or a note that the statement does nothing when an equality test is used instead of an assignment outside of a conditional. This is one issue that is essentially fixable -- if you use the higher warning levels.

          Or: https://softwareengineering.stackexchange.com/questions/162256/in-c-and-c-what-methods-can-prevent-accidental-use-of-the-assignment-where

          ?

          EDIT

          OK, what about https://msdn.microsoft.com/en-us/library/7hw7c1he.aspx

          Compiler Warning (level 4) C4706

          It's in /W4, which I always use, and is equivalent to gcc's -Wall.

          And BTW MSVC does not accept double-parentheses to suppress this, you have to write:

          if ((isMouseDown = true) == true)
          
          J.HilkJ 1 Reply Last reply
          0
          • JonBJ JonB

            @J.Hilk
            I have been using Visual Studio (outside of Qt) for, umm, 20 years, and I'm sure there must be a similar warning for "possibly unintended assignment inside condition", isn't there...??

            I Googled across, say, http://www.learncpp.com/cpp-programming/eight-c-programming-mistakes-the-compiler-wont-catch/

            Running a modern compiler at the highest warning level will cause it to issue a warning when an assignment is used in a conditional statement, or a note that the statement does nothing when an equality test is used instead of an assignment outside of a conditional. This is one issue that is essentially fixable -- if you use the higher warning levels.

            Or: https://softwareengineering.stackexchange.com/questions/162256/in-c-and-c-what-methods-can-prevent-accidental-use-of-the-assignment-where

            ?

            EDIT

            OK, what about https://msdn.microsoft.com/en-us/library/7hw7c1he.aspx

            Compiler Warning (level 4) C4706

            It's in /W4, which I always use, and is equivalent to gcc's -Wall.

            And BTW MSVC does not accept double-parentheses to suppress this, you have to write:

            if ((isMouseDown = true) == true)
            
            J.HilkJ Offline
            J.HilkJ Offline
            J.Hilk
            Moderators
            wrote on last edited by
            #10

            @JonB
            on higher warning levels this might indeed be true, I did just a quick test with the default settings.

            int main(int argc, char *argv[])
            {
                QApplication a(argc, argv);
            
                int ab;
                if(ab = 2)
                    qDebug() << "True" << ab;
                else
                    qDebug() << "False" << ab;
            
               return a.exec();
            }
            

            and got no warnings with MSVC and a warning with mingw
            0_1526555924345_d7fe3fda-7318-40f1-8e5e-bf4723ba6140-image.png


            Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


            Q: What's that?
            A: It's blue light.
            Q: What does it do?
            A: It turns blue.

            JonBJ 1 Reply Last reply
            0
            • J.HilkJ J.Hilk

              @JonB
              on higher warning levels this might indeed be true, I did just a quick test with the default settings.

              int main(int argc, char *argv[])
              {
                  QApplication a(argc, argv);
              
                  int ab;
                  if(ab = 2)
                      qDebug() << "True" << ab;
                  else
                      qDebug() << "False" << ab;
              
                 return a.exec();
              }
              

              and got no warnings with MSVC and a warning with mingw
              0_1526555924345_d7fe3fda-7318-40f1-8e5e-bf4723ba6140-image.png

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

              @J.Hilk
              See my edits above. For MSVC use /W4 just as you would use gcc -Wall. I always expect to do that, and would advise this OP to do so too.

              J.HilkJ 1 Reply Last reply
              0
              • JonBJ JonB

                @J.Hilk
                See my edits above. For MSVC use /W4 just as you would use gcc -Wall. I always expect to do that, and would advise this OP to do so too.

                J.HilkJ Offline
                J.HilkJ Offline
                J.Hilk
                Moderators
                wrote on last edited by
                #12

                @JonB
                mmh, adding

                QMAKE_CXXFLAGS_WARN_ON -= -W3
                QMAKE_CXXFLAGS_WARN_ON += -W4
                

                or

                QMAKE_CFLAGS_WARN_ON -= -W3
                QMAKE_CFLAGS_WARN_ON += -W4
                

                still produces no warning.
                Seems like I have to google how to do change the warning lvl in QtCreator x)


                Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


                Q: What's that?
                A: It's blue light.
                Q: What does it do?
                A: It turns blue.

                JonBJ 1 Reply Last reply
                0
                • J.HilkJ J.Hilk

                  @JonB
                  mmh, adding

                  QMAKE_CXXFLAGS_WARN_ON -= -W3
                  QMAKE_CXXFLAGS_WARN_ON += -W4
                  

                  or

                  QMAKE_CFLAGS_WARN_ON -= -W3
                  QMAKE_CFLAGS_WARN_ON += -W4
                  

                  still produces no warning.
                  Seems like I have to google how to do change the warning lvl in QtCreator x)

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

                  @J.Hilk
                  First check out that you do indeed get that warning with explicit command-line compile of a test program outside of Qt. I was only quoting from what I randomly Googled for....

                  J.HilkJ 1 Reply Last reply
                  0
                  • JonBJ JonB

                    @J.Hilk
                    First check out that you do indeed get that warning with explicit command-line compile of a test program outside of Qt. I was only quoting from what I randomly Googled for....

                    J.HilkJ Offline
                    J.HilkJ Offline
                    J.Hilk
                    Moderators
                    wrote on last edited by
                    #14

                    @JonB
                    I can confirm, w4 catches it :-)

                    0_1526557925007_90985ca6-93a1-4271-b2e0-43f76104365b-image.png


                    Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


                    Q: What's that?
                    A: It's blue light.
                    Q: What does it do?
                    A: It turns blue.

                    1 Reply Last reply
                    1
                    • S Offline
                      S Offline
                      saber
                      wrote on last edited by saber
                      #15

                      i have a suggestion .
                      use qpoint instead of "offset_X_Coordinate;"& "offset_Y_Coordinate;"

                      1 Reply Last reply
                      1

                      • Login

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