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. How to create VS2013 like frameless window with dark style
Forum Updated to NodeBB v4.3 + New Features

How to create VS2013 like frameless window with dark style

Scheduled Pinned Locked Moved Unsolved General and Desktop
45 Posts 5 Posters 18.2k Views 5 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.
  • S saeid0034

    @mrjj said in How to create VS2013 like frameless window with dark style:

    @saeid0034
    so you did try with
    FramelessWindow framelessWindow;
    FramelessWindow framelessWindow2;

    and it wont show ?

    also the on_pushButton_clicked will just make a new one and NOT USE frameless as you dont add that ot it like you do in main.

    what can i do?
    you mean i need somthing like this in my mainwindow.cpp?

    void MainWindow::on_pushButton_clicked()
    {
        // ----- Hide old Window and show new window ----- //
         hide();
    
         // style our application with custom dark style
         setStyle(new DarkStyle);
    
         // create frameless window (and set windowState or title)
         FramelessWindow framelessWindow2;
         //framelessWindow.setWindowState(Qt::WindowMaximized);
         framelessWindow2.setWindowTitle(".r");
         framelessWindow2.setWindowIcon(QIcon(":/png/sr-removebg-preview.png"));
    
         // create our mainwindow instance
         MainWindow2 *mainwindow2 = new MainWindow2;
    
         // add the mainwindow to our custom frameless window
         framelessWindow2.setContent(mainwindow2);
         framelessWindow2.show();
    
         //mainwindow2 = new MainWindow2(this);
    }
    

    sorry for asking lots of question (and sorry about mistake in framelessWindow2.setWindowTitle in above code)

    S Offline
    S Offline
    saeid0034
    wrote on last edited by
    #25
    This post is deleted!
    1 Reply Last reply
    0
    • mrjjM mrjj

      Hi
      seems ok.
      Yes you need to to the same each time you create a Window you want to be frame less

      one thing.

      setStyle(new DarkStyle);

      that sets on the current MainWindow and i thnik you need that on the new one

      // create our mainwindow instance
      MainWindow2 *mainwindow2 = new MainWindow2;
      mainwindow2 -> setStyle(new DarkStyle);

      • sorry for asking lots of question
        That is quite allright :)
      S Offline
      S Offline
      saeid0034
      wrote on last edited by saeid0034
      #26

      @mrjj said in How to create VS2013 like frameless window with dark style:

      Hi
      seems ok.
      Yes you need to to the same each time you create a Window you want to be frame less

      one thing.

      setStyle(new DarkStyle);

      that sets on the current MainWindow and i thnik you need that on the new one

      // create our mainwindow instance
      MainWindow2 *mainwindow2 = new MainWindow2;
      mainwindow2 -> setStyle(new DarkStyle);

      • sorry for asking lots of question
        That is quite allright :)

      i tested it with following code

               hide();
               // create frameless window (and set windowState or title)
               FramelessWindow framelessWindow2;
               //framelessWindow.setWindowState(Qt::WindowMaximized);
               framelessWindow2.setWindowTitle(".r");
               framelessWindow2.setWindowIcon(QIcon(":/png/sr-removebg-preview.png"));
      
               // create our mainwindow instance
               MainWindow2 *mainwindow2 = new MainWindow2;
               mainwindow2 -> setStyle(new DarkStyle);
      
               // add the mainwindow to our custom frameless window
               framelessWindow2.setContent(mainwindow2);
               framelessWindow2.show();
      
               //mainwindow2 = new MainWindow2(this);
      

      but again it show me only a blank frameless window of my second ui file

      bdc7674c-a57e-441e-869c-56bbf4dd7ac8-image.png

      one other point is as you can see WindowTitle is test (i use this title in my frist windown in main.cpp) its not use new WindowTitle i set in above code

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

        Hi
        Sorry was not paying enough focus.

        You cannot do
        FramelessWindow framelessWindow2;

        as it will run out of scope. That only works in main.cpp

        you MUST new them as you do with MainWindow

        S 1 Reply Last reply
        1
        • mrjjM mrjj

          Hi
          Sorry was not paying enough focus.

          You cannot do
          FramelessWindow framelessWindow2;

          as it will run out of scope. That only works in main.cpp

          you MUST new them as you do with MainWindow

          S Offline
          S Offline
          saeid0034
          wrote on last edited by
          #28

          @mrjj said in How to create VS2013 like frameless window with dark style:

          Hi
          Sorry was not paying enough focus.

          You cannot do
          FramelessWindow framelessWindow2;

          as it will run out of scope. That only works in main.cpp

          you MUST new them as you do with MainWindow

          how can i add new FramelessWindow framelessWindow2 in main.cpp and then use it onvoid MainWindow::on_pushButton_clicked()in mainwindow.cpp?

          mrjjM 1 Reply Last reply
          0
          • S saeid0034

            @mrjj said in How to create VS2013 like frameless window with dark style:

            Hi
            Sorry was not paying enough focus.

            You cannot do
            FramelessWindow framelessWindow2;

            as it will run out of scope. That only works in main.cpp

            you MUST new them as you do with MainWindow

            how can i add new FramelessWindow framelessWindow2 in main.cpp and then use it onvoid MainWindow::on_pushButton_clicked()in mainwindow.cpp?

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

            @saeid0034

            Hi you dont need to add it there you can add anywhere but you must NEW it then

            and not as local variable as then it runs out of scope.

            So what i mean is just to do
            FramelessWindow * framelessWindow2 = new FramelessWindow ;

            and not just
            FramelessWindow framelessWindow2; // this is a local variable and as soon as
            on_pushButton_clicked ends , it will be deleted

            so you have to new it

            1 Reply Last reply
            1
            • S Offline
              S Offline
              saeid0034
              wrote on last edited by saeid0034
              #30

              @mrjj said in How to create VS2013 like frameless window with dark style:

              FramelessWindow * framelessWindow2 = new FramelessWindow ;

              thanks
              i do what you say
              this time second window open when i click button
              but old blank frameless window still open too

              af260e6b-83bc-4dd7-bac3-99f04c4fba50-image.png

              void MainWindow::on_pushButton_clicked()
              {
                  // ----- Hide old Window and show new window ----- //
                   hide();
                   FramelessWindow * framelessWindow2 = new FramelessWindow ;
                   // style our application with custom dark style
                   setStyle(new DarkStyle);
                   //framelessWindow.setWindowState(Qt::WindowMaximized);
                   framelessWindow2->setWindowTitle("test");
                   framelessWindow2->setWindowIcon(QIcon(":/png/sr-removebg-preview.png"));
              
                   // create our mainwindow instance
                   MainWindow2 *mainwindow2 = new MainWindow2;
              
                   // add the mainwindow to our custom frameless window
                   framelessWindow2->setContent(mainwindow2);
                   framelessWindow2->show();
              }
              
              mrjjM 1 Reply Last reply
              0
              • S saeid0034

                @mrjj said in How to create VS2013 like frameless window with dark style:

                FramelessWindow * framelessWindow2 = new FramelessWindow ;

                thanks
                i do what you say
                this time second window open when i click button
                but old blank frameless window still open too

                af260e6b-83bc-4dd7-bac3-99f04c4fba50-image.png

                void MainWindow::on_pushButton_clicked()
                {
                    // ----- Hide old Window and show new window ----- //
                     hide();
                     FramelessWindow * framelessWindow2 = new FramelessWindow ;
                     // style our application with custom dark style
                     setStyle(new DarkStyle);
                     //framelessWindow.setWindowState(Qt::WindowMaximized);
                     framelessWindow2->setWindowTitle("test");
                     framelessWindow2->setWindowIcon(QIcon(":/png/sr-removebg-preview.png"));
                
                     // create our mainwindow instance
                     MainWindow2 *mainwindow2 = new MainWindow2;
                
                     // add the mainwindow to our custom frameless window
                     framelessWindow2->setContent(mainwindow2);
                     framelessWindow2->show();
                }
                
                mrjjM Offline
                mrjjM Offline
                mrjj
                Lifetime Qt Champion
                wrote on last edited by
                #31

                @saeid0034
                The other empty one, is that from you create 2 in main.cpp or
                do you only create one there?

                S 1 Reply Last reply
                1
                • mrjjM mrjj

                  @saeid0034
                  The other empty one, is that from you create 2 in main.cpp or
                  do you only create one there?

                  S Offline
                  S Offline
                  saeid0034
                  wrote on last edited by
                  #32

                  @mrjj said in How to create VS2013 like frameless window with dark style:

                  @saeid0034
                  The other empty one, is that from you create 2 in main.cpp or
                  do you only create one there?

                  i only create one
                  i send the code im used

                  mrjjM 1 Reply Last reply
                  0
                  • S saeid0034

                    @mrjj said in How to create VS2013 like frameless window with dark style:

                    @saeid0034
                    The other empty one, is that from you create 2 in main.cpp or
                    do you only create one there?

                    i only create one
                    i send the code im used

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

                    @saeid0034
                    Ok i think we need to hide the parent too.
                    instead of
                    // ----- Hide old Window and show new window ----- //
                    hide();
                    try
                    parentWidget()->hide();
                    to hide the framelss instead of the MainWIn we put inside.

                    S 1 Reply Last reply
                    1
                    • mrjjM mrjj

                      @saeid0034
                      Ok i think we need to hide the parent too.
                      instead of
                      // ----- Hide old Window and show new window ----- //
                      hide();
                      try
                      parentWidget()->hide();
                      to hide the framelss instead of the MainWIn we put inside.

                      S Offline
                      S Offline
                      saeid0034
                      wrote on last edited by
                      #34

                      @mrjj said in How to create VS2013 like frameless window with dark style:

                      parentWidget()->hide();

                      still two window
                      but this time with this look
                      163df581-c83d-4477-8284-7264a4cb9f50-image.png

                      mrjjM 1 Reply Last reply
                      0
                      • S saeid0034

                        @mrjj said in How to create VS2013 like frameless window with dark style:

                        parentWidget()->hide();

                        still two window
                        but this time with this look
                        163df581-c83d-4477-8284-7264a4cb9f50-image.png

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

                        @saeid0034
                        Hmm so apparently the FrameLess is not the actual parent. must be a holding frame or something.
                        (i dont have it installed )

                        try
                        if (parentWidget()->parentWidget())
                        parentWidget()->parentWidget()->hide();

                        and see if thats enough :)

                        S 1 Reply Last reply
                        1
                        • mrjjM mrjj

                          @saeid0034
                          Hmm so apparently the FrameLess is not the actual parent. must be a holding frame or something.
                          (i dont have it installed )

                          try
                          if (parentWidget()->parentWidget())
                          parentWidget()->parentWidget()->hide();

                          and see if thats enough :)

                          S Offline
                          S Offline
                          saeid0034
                          wrote on last edited by
                          #36

                          @mrjj said in How to create VS2013 like frameless window with dark style:

                          if (parentWidget()->parentWidget())
                          parentWidget()->parentWidget()->hide();

                          Thanks
                          the blank window disappeared but it still open as you can see
                          07dd8539-41f2-4726-9dd2-7f8197079a7e-image.png

                          mrjjM 1 Reply Last reply
                          0
                          • S saeid0034

                            @mrjj said in How to create VS2013 like frameless window with dark style:

                            if (parentWidget()->parentWidget())
                            parentWidget()->parentWidget()->hide();

                            Thanks
                            the blank window disappeared but it still open as you can see
                            07dd8539-41f2-4726-9dd2-7f8197079a7e-image.png

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

                            @saeid0034
                            But its not on screen any more?
                            Is that with alt+tab ?

                            S 1 Reply Last reply
                            1
                            • mrjjM mrjj

                              @saeid0034
                              But its not on screen any more?
                              Is that with alt+tab ?

                              S Offline
                              S Offline
                              saeid0034
                              wrote on last edited by
                              #38

                              @mrjj said in How to create VS2013 like frameless window with dark style:

                              @saeid0034
                              But its not on screen any more?
                              Is that with alt+tab ?

                              yes it not on screen anymore but still open
                              yest i take screen shot from alt+tab
                              17c59b1d-cba7-4cb9-9d7d-909f3c134e12-image.png

                              mrjjM 1 Reply Last reply
                              0
                              • S saeid0034

                                @mrjj said in How to create VS2013 like frameless window with dark style:

                                @saeid0034
                                But its not on screen any more?
                                Is that with alt+tab ?

                                yes it not on screen anymore but still open
                                yest i take screen shot from alt+tab
                                17c59b1d-cba7-4cb9-9d7d-909f3c134e12-image.png

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

                                @saeid0034
                                Hmm very odd. I think it might be something stil from FrameLess but not sure what it is.

                                S 1 Reply Last reply
                                1
                                • mrjjM mrjj

                                  @saeid0034
                                  Hmm very odd. I think it might be something stil from FrameLess but not sure what it is.

                                  S Offline
                                  S Offline
                                  saeid0034
                                  wrote on last edited by saeid0034
                                  #40

                                  @mrjj said in How to create VS2013 like frameless window with dark style:

                                  @saeid0034
                                  Hmm very odd. I think it might be something stil from FrameLess but not sure what it is.

                                  you think there is no way to fix that?
                                  i use it for my whole project

                                  mrjjM 1 Reply Last reply
                                  0
                                  • S saeid0034

                                    @mrjj said in How to create VS2013 like frameless window with dark style:

                                    @saeid0034
                                    Hmm very odd. I think it might be something stil from FrameLess but not sure what it is.

                                    you think there is no way to fix that?
                                    i use it for my whole project

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

                                    @saeid0034
                                    Hi
                                    Im pretty sure all of it can be hidden as its just widgets but not sure
                                    what that invisible caption really is.
                                    inside it just does
                                    ui->windowContent->layout()->addWidget(w);

                                    so parentWidget()->parentWidget()->hide(); should do it but
                                    maybe there is something else it creates like maybe the fake caption we can see of something like that.

                                    S 1 Reply Last reply
                                    1
                                    • mrjjM mrjj

                                      @saeid0034
                                      Hi
                                      Im pretty sure all of it can be hidden as its just widgets but not sure
                                      what that invisible caption really is.
                                      inside it just does
                                      ui->windowContent->layout()->addWidget(w);

                                      so parentWidget()->parentWidget()->hide(); should do it but
                                      maybe there is something else it creates like maybe the fake caption we can see of something like that.

                                      S Offline
                                      S Offline
                                      saeid0034
                                      wrote on last edited by
                                      #42

                                      @mrjj there is anything i can do with it?
                                      this framelees is really good but if only i can fix this problem

                                      mrjjM 1 Reply Last reply
                                      0
                                      • S saeid0034

                                        @mrjj there is anything i can do with it?
                                        this framelees is really good but if only i can fix this problem

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

                                        @saeid0034
                                        Dont worry, we will nail it.

                                        replace

                                        if (parentWidget()->parentWidget())
                                        parentWidget()->parentWidget()->hide();
                                        

                                        with

                                          auto w = parentWidget();
                                            while ( w ) {
                                                w->hide();
                                                w = w->parentWidget();
                                            }
                                        

                                        this hides the sample it comes with. Nothing in alt+tab after. So i cross fingers :)

                                        S 1 Reply Last reply
                                        1
                                        • mrjjM mrjj

                                          @saeid0034
                                          Dont worry, we will nail it.

                                          replace

                                          if (parentWidget()->parentWidget())
                                          parentWidget()->parentWidget()->hide();
                                          

                                          with

                                            auto w = parentWidget();
                                              while ( w ) {
                                                  w->hide();
                                                  w = w->parentWidget();
                                              }
                                          

                                          this hides the sample it comes with. Nothing in alt+tab after. So i cross fingers :)

                                          S Offline
                                          S Offline
                                          saeid0034
                                          wrote on last edited by
                                          #44

                                          @mrjj said in How to create VS2013 like frameless window with dark style:

                                          auto w = parentWidget();
                                          while ( w ) {
                                          w->hide();
                                          w = w->parentWidget();
                                          }

                                          thanks man
                                          this time only a window open
                                          f17d9e4b-8a06-459a-b5ff-5ff6e463acf6-image.png
                                          thanks for all your helps

                                          mrjjM 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