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. FramelessWindowHint fails at runtime on MainWindow
Forum Updated to NodeBB v4.3 + New Features

FramelessWindowHint fails at runtime on MainWindow

Scheduled Pinned Locked Moved Solved General and Desktop
13 Posts 3 Posters 8.9k Views 2 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.
  • mrjjM Offline
    mrjjM Offline
    mrjj
    Lifetime Qt Champion
    wrote on last edited by
    #2

    @Rory_1 said:

    Qt::FramelessWindowHint

    Might be bug in newer version
    https://forum.qt.io/topic/53502/toggle-window-frames-qt-framelesswindowhint-in-qt-5-4-1

    why cant you just set in constructor ?
    need to toggle it ?

    R 1 Reply Last reply
    0
    • mrjjM mrjj

      @Rory_1 said:

      Qt::FramelessWindowHint

      Might be bug in newer version
      https://forum.qt.io/topic/53502/toggle-window-frames-qt-framelesswindowhint-in-qt-5-4-1

      why cant you just set in constructor ?
      need to toggle it ?

      R Offline
      R Offline
      Rory_1
      wrote on last edited by
      #3

      @mrjj

      Yes, I want to toggle.

      mrjjM 1 Reply Last reply
      0
      • R Rory_1

        @mrjj

        Yes, I want to toggle.

        mrjjM Offline
        mrjjM Offline
        mrjj
        Lifetime Qt Champion
        wrote on last edited by
        #4

        @Rory_1
        ok. i get same result on win 7, qt 5.5 so its a bug it seems.

        there is showFullScreen(); if you need for something like that.

        can I ask what case you need borderless window for?

        R 1 Reply Last reply
        0
        • mrjjM mrjj

          @Rory_1
          ok. i get same result on win 7, qt 5.5 so its a bug it seems.

          there is showFullScreen(); if you need for something like that.

          can I ask what case you need borderless window for?

          R Offline
          R Offline
          Rory_1
          wrote on last edited by Rory_1
          #5

          @mrjj

          Mainly for ascetics and screen real estate. I am building a raw image viewer and want to be able to toggle to a slideshow view to maximize the image size. When viewing images vertical space is always at a premium for portrait oriented images, so anything I can eliminate is helpful.

          mrjjM 1 Reply Last reply
          0
          • R Rory_1

            @mrjj

            Mainly for ascetics and screen real estate. I am building a raw image viewer and want to be able to toggle to a slideshow view to maximize the image size. When viewing images vertical space is always at a premium for portrait oriented images, so anything I can eliminate is helpful.

            mrjjM Offline
            mrjjM Offline
            mrjj
            Lifetime Qt Champion
            wrote on last edited by
            #6

            @mrjj said:

            well I assume fullscreen is too drastic ?

            One option you have is to use a dialog for viewing the image. When change to borderless mode, you can simply
            create a new instance where you set the flag in the constructor. (and delete the old one)

            It would also be possible to do this with mainwindow from main, but would be slightly more haxish.

            1 Reply Last reply
            0
            • Chris KawaC Offline
              Chris KawaC Offline
              Chris Kawa
              Lifetime Qt Champion
              wrote on last edited by
              #7

              That's not a bug. That's just how window managers work. You shouldn't change the frame on a visible window.
              And btw. you should just add the hint, not replace all of them i.e. to make it frameless:

              hide();
              setWindowFlags(windowFlags() | Qt::FramelessWindowHint);
              show();
              

              and to go back:

              hide();
              setWindowFlags(windowFlags() & ~Qt::FramelessWindowHint);
              show();
              
              R 1 Reply Last reply
              3
              • mrjjM Offline
                mrjjM Offline
                mrjj
                Lifetime Qt Champion
                wrote on last edited by
                #8

                setWindowFlags(windowFlags() | Qt::FramelessWindowHint);

                So clear when you see it :)

                Can you tell why it does seem work in ctor after ui setup
                setWindowFlags(Qt::FramelessWindowHint);

                Even if not OR ing.

                1 Reply Last reply
                1
                • Chris KawaC Offline
                  Chris KawaC Offline
                  Chris Kawa
                  Lifetime Qt Champion
                  wrote on last edited by Chris Kawa
                  #9

                  Can you tell why it does seem work in ctor after ui setup

                  It's an (un)fortunate coincidence. The default flags are something like:
                  Window|WindowTitleHint|WindowSystemMenuHint|WindowMinMaxButtonsHint|WindowCloseButtonHint|WindowFullscreenButtonHint
                  If you call setWindowFlags(Qt::FramelessWindowHint) it becomes Window|FramelessWindowHint (you can't really loose the Window flag), so you loose all the hint flags. It seems to work, since frameless window doesn't use them anyway, but if you tried to go back or if somebody set some other flags (either with setWindowFlags or via the second param of QWidget's constructor) you'd loose them and had no way to know what they were.

                  As to why did the setWindowFlags call seem to work in the constructor and didn't later, it's because when a constructor is run the widget is not yet shown, so changing flags is ok there.

                  1 Reply Last reply
                  1
                  • mrjjM Offline
                    mrjjM Offline
                    mrjj
                    Lifetime Qt Champion
                    wrote on last edited by
                    #10

                    Ah so cannot really clear the Window flag and hence we see no ill effect when only using the default values.
                    So always OR. Even in ctor.

                    1 Reply Last reply
                    0
                    • Chris KawaC Chris Kawa

                      That's not a bug. That's just how window managers work. You shouldn't change the frame on a visible window.
                      And btw. you should just add the hint, not replace all of them i.e. to make it frameless:

                      hide();
                      setWindowFlags(windowFlags() | Qt::FramelessWindowHint);
                      show();
                      

                      and to go back:

                      hide();
                      setWindowFlags(windowFlags() & ~Qt::FramelessWindowHint);
                      show();
                      
                      R Offline
                      R Offline
                      Rory_1
                      wrote on last edited by
                      #11

                      @Chris-Kawa

                      Thanks so much Chris for the solution and the clear explanation. Sorry about my inexperience, but how do I show the issue has been solved?

                      Best regards
                      Rory

                      mrjjM 1 Reply Last reply
                      0
                      • R Rory_1

                        @Chris-Kawa

                        Thanks so much Chris for the solution and the clear explanation. Sorry about my inexperience, but how do I show the issue has been solved?

                        Best regards
                        Rory

                        mrjjM Offline
                        mrjjM Offline
                        mrjj
                        Lifetime Qt Champion
                        wrote on last edited by mrjj
                        #12

                        @Rory_1
                        hi
                        Use the Topic Tools button to mark as Solved.
                        its sort below topic/post to the right.

                        R 1 Reply Last reply
                        0
                        • mrjjM mrjj

                          @Rory_1
                          hi
                          Use the Topic Tools button to mark as Solved.
                          its sort below topic/post to the right.

                          R Offline
                          R Offline
                          Rory_1
                          wrote on last edited by
                          #13

                          @mrjj Thanks!

                          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