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. Can we remove Dialog or Mainwindow written on the top of Application output.
Forum Updated to NodeBB v4.3 + New Features

Can we remove Dialog or Mainwindow written on the top of Application output.

Scheduled Pinned Locked Moved Solved General and Desktop
34 Posts 6 Posters 4.2k 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.
  • J.HilkJ J.Hilk

    @JonB oh,
    I only read the title of this thread ...

    Can we remove Dialog or Mainwindow written on the top of Application output.

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

    @J-Hilk Always pays to read the body of threads too ;-)

    1 Reply Last reply
    1
    • jsulmJ jsulm

      @Ashutosh_Sachdeva said in Can we remove Dialog or Mainwindow written on the top of Application output.:

      ui->frame->setWindowFlag(Qt::FramelessWindowHint ,true);

      Please read again what @mrjj suggested: he suggested to call setWindowFlag(Qt::FramelessWindowHint,true); without ui->frame-> in front of it...

      A Offline
      A Offline
      Ashutosh_Sachdeva
      wrote on last edited by
      #15

      @jsulm

      Yeah tried but its throwing below mentioned error

      /home/ashutosh/Ashu_QT/Main_Demo/menu.cpp:10: error: 'setWindowFlag' was not declared in this scope
      setWindowFlag(Qt::FramelessWindowHint,true);

      //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
      i have tried with this "setWindowFlags(Qt::FramelessWindowHint);" as well and thus function is closing the whole window.

      jsulmJ 1 Reply Last reply
      0
      • A Ashutosh_Sachdeva

        @jsulm

        Yeah tried but its throwing below mentioned error

        /home/ashutosh/Ashu_QT/Main_Demo/menu.cpp:10: error: 'setWindowFlag' was not declared in this scope
        setWindowFlag(Qt::FramelessWindowHint,true);

        //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        i have tried with this "setWindowFlags(Qt::FramelessWindowHint);" as well and thus function is closing the whole window.

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

        @Ashutosh_Sachdeva Please show your code, I do not want to guess...

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

        A 1 Reply Last reply
        0
        • JonBJ JonB

          @J-Hilk

          I think my fellow poster's may lead you in the wrong direction.

          Nah, I don't think so. The OP wrote:

          Can we remove the dialog/Black menu line written on the top of the output screen
          Yes i have taken dialog box without buttons and i want o remove that dialog caption and that black line

          I think the "black line" does mean he wants the whole of the dialog title (including the button furniture at top-left, whether he has realized that or not) removed, not just the title string itself.

          So he needs to try dialog->setWindowFlag(Qt::FramelessWindowHint, true);, or this->setWindowFlag(Qt::FramelessWindowHint, true); if he is inside QDialog-derived code.

          A Offline
          A Offline
          Ashutosh_Sachdeva
          wrote on last edited by
          #17

          @JonB

          Sorry, may be i'm doing something wrong but i'm not able to find anyfunction named "Setwindoflag" (this can be stupid but i don't know why this is happening) . And i'f i'm using "setwindowflags" this function is closing the complete page.

          jsulmJ JonBJ 2 Replies Last reply
          0
          • jsulmJ jsulm

            @Ashutosh_Sachdeva Please show your code, I do not want to guess...

            A Offline
            A Offline
            Ashutosh_Sachdeva
            wrote on last edited by Ashutosh_Sachdeva
            #18
            This post is deleted!
            1 Reply Last reply
            0
            • A Ashutosh_Sachdeva

              @JonB

              Sorry, may be i'm doing something wrong but i'm not able to find anyfunction named "Setwindoflag" (this can be stupid but i don't know why this is happening) . And i'f i'm using "setwindowflags" this function is closing the complete page.

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

              @Ashutosh_Sachdeva said in Can we remove Dialog or Mainwindow written on the top of Application output.:

              And i'f i'm using "setwindowflags" this function is closing the complete page

              If using setWindowFlags you need to keep all other flags:

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

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

              1 Reply Last reply
              2
              • A Ashutosh_Sachdeva

                @JonB

                Sorry, may be i'm doing something wrong but i'm not able to find anyfunction named "Setwindoflag" (this can be stupid but i don't know why this is happening) . And i'f i'm using "setwindowflags" this function is closing the complete page.

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

                @Ashutosh_Sachdeva said in Can we remove Dialog or Mainwindow written on the top of Application output.:

                @JonB
                Sorry, may be i'm doing something wrong but i'm not able to find anyfunction named "Setwindoflag" (this can be stupid but i don't know why this is happening) . And i'f i'm using "setwindowflags" this function is closing the complete page.

                At no point do I see Setwindoflag [sic.] written by any of us, so why do you write that? Did you search in the documentation for setWindowFlag, where you would have come across https://doc.qt.io/qt-5/qwidget.html#setWindowFlag? Not too hard to find. I have no idea what you mean by "And i'f i'm using "setwindowflags" this function is closing the complete page.", but never mind.

                In your code I see:

                //setWindowFlags(Qt::FramelessWindowHint);
                this->setWindowFlags(Qt::FramelessWindowHint,true);

                I don't think the second line should even compile.

                You have a class named Menu which derives from QDialog. This is not a helpful name, especially since Qt has a QMenu which is what I initially thought your code would be about. You might like to think about renaming that.

                You have pasted hundreds of lines of your code when all you are asking is how to suppress the dialog's title bar.

                You need to try exactly what we have been saying. In place of your own attempts at the start of Menu::Menu(), have you tried:

                setWindowFlag(Qt::FramelessWindowHint, true);
                

                If you have, and it gives

                error: 'setWindowFlag' was not declared in this scope
                

                then I would guess you are on a Qt version prior to 5.9? In which case (apart from why not a later one?) it would really help if you said so! As you can see from the doc page, setWindowFlag() was introduced in Qt 5.9. If you are earlier try instead:

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

                Please use copy & paste to ensure you get this as written.

                At that point, does it indeed compile and get rid of the dialog's title bar, as I believe you were asking for?

                I have had my grump in this reply :) I hope the above does work for you.

                1 Reply Last reply
                3
                • A Offline
                  A Offline
                  Ashutosh_Sachdeva
                  wrote on last edited by
                  #21

                  @jsulm
                  Thanku So much Sir. setWindowFlags(windowFlags() | Qt::FramelessWindowHint); working fine.

                  1 Reply Last reply
                  0
                  • A Offline
                    A Offline
                    Ashutosh_Sachdeva
                    wrote on last edited by Ashutosh_Sachdeva
                    #22

                    @mrjj @jsulm Thanku so much guys for spearing your time and helping. You guys are helping a me lot in learning QT.

                    1 Reply Last reply
                    0
                    • A Offline
                      A Offline
                      Ashutosh_Sachdeva
                      wrote on last edited by
                      #23

                      @jsulm Hi,

                      I have one more doubt here as now i have deleted that main-window title and menu bar so if now i want to come back to my previous page then what will be the method to close current page and go back to previous

                      1 Reply Last reply
                      0
                      • JonBJ Online
                        JonBJ Online
                        JonB
                        wrote on last edited by JonB
                        #24

                        Ah well, @mrjj & @jsulm get all the thanks, even when quoting the code I typed into my reply for pre-5.9 which is what the OP needed for his solution (edit whoops, bad hair day :) ). Perhaps I shouldn't have typed in all the stuff it took me time to do....

                        A 1 Reply Last reply
                        0
                        • JonBJ JonB

                          Ah well, @mrjj & @jsulm get all the thanks, even when quoting the code I typed into my reply for pre-5.9 which is what the OP needed for his solution (edit whoops, bad hair day :) ). Perhaps I shouldn't have typed in all the stuff it took me time to do....

                          A Offline
                          A Offline
                          Ashutosh_Sachdeva
                          wrote on last edited by
                          #25

                          @JonB
                          Hello Sir,

                          Thanku so much and i really appreciate that u have speared your precious time to help and it really helpful for me and as a beginner i have a lot of thing to learn from you guys. And also looking forward for more help from you. And sorry that i missed the stuff some how as i saw the top reply and it solved the problem too.

                          Thanku once again for the help and looking toward to learn more from you.

                          JonBJ 1 Reply Last reply
                          1
                          • A Ashutosh_Sachdeva

                            @JonB
                            Hello Sir,

                            Thanku so much and i really appreciate that u have speared your precious time to help and it really helpful for me and as a beginner i have a lot of thing to learn from you guys. And also looking forward for more help from you. And sorry that i missed the stuff some how as i saw the top reply and it solved the problem too.

                            Thanku once again for the help and looking toward to learn more from you.

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

                            @Ashutosh_Sachdeva
                            Sorry, you are right. I now see @jsulm posted

                            If using setWindowFlags you need to keep all other flags:

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

                            I truly never spotted that he had offered that! My bad! I get tetchy... ;-)

                            1 Reply Last reply
                            0
                            • A Offline
                              A Offline
                              Ashutosh_Sachdeva
                              wrote on last edited by
                              #27

                              @JonB
                              I have one more doubt here as now i have deleted that main-window title and menu bar so if now i want to come back to my previous page then what will be the method to close current page and go back to previous.

                              as this->hide will hide the previous page but i want to store the status of current page as if i want to go back i can go back to previous page or my main menu page.

                              I hope i'm able to explain my requirement

                              JonBJ 1 Reply Last reply
                              0
                              • A Ashutosh_Sachdeva

                                @JonB
                                I have one more doubt here as now i have deleted that main-window title and menu bar so if now i want to come back to my previous page then what will be the method to close current page and go back to previous.

                                as this->hide will hide the previous page but i want to store the status of current page as if i want to go back i can go back to previous page or my main menu page.

                                I hope i'm able to explain my requirement

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

                                @Ashutosh_Sachdeva
                                Deleting title bars does not affect anything.

                                While you are dealing with (modal) dialogs the "going back" does not apply, you don't leave the calling page.

                                If you have separate windows somewhere, and you want to display one at a time and navigate between them, use QStackedWidget. This will preserve state, and you won't be using hide/show yourself. (Having said that, it will use hide/show internally, using those on windows/widgets does not lose state.)

                                1 Reply Last reply
                                0
                                • A Offline
                                  A Offline
                                  Ashutosh_Sachdeva
                                  wrote on last edited by
                                  #29

                                  @JonB

                                  OK, But what i'm asking for ex. i have one menu page and there is one drop down menu, now if i click on one of the item from menu it will take me to that page and now if i want to back to menu page then how can i go as now we have a window without any cross button on the left corner to close the window.

                                  "for ex. i saw somewhere if we click right button of the mouse then current page will be closed and it will take us to main menu page back and so on."

                                  JonBJ 1 Reply Last reply
                                  0
                                  • A Ashutosh_Sachdeva

                                    @JonB

                                    OK, But what i'm asking for ex. i have one menu page and there is one drop down menu, now if i click on one of the item from menu it will take me to that page and now if i want to back to menu page then how can i go as now we have a window without any cross button on the left corner to close the window.

                                    "for ex. i saw somewhere if we click right button of the mouse then current page will be closed and it will take us to main menu page back and so on."

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

                                    @Ashutosh_Sachdeva

                                    • I don't understand your "menus" sometimes a menu seems to mean a dialog and sometimes it seems to mean some dropdown menu. Which is why I said you might wish to change your terminology, for precisely this reason.

                                    • As I said, if your "menu" is a "modal dialog" which you call exec() on, afterward you will be back in the calling page.

                                    • Yes, if you choose to remove the title bar on a window/dialog which has the close button then you won't have a close button to press, as I mentioned earlier. You will have to provide some other means (button, key press, right-click, whatever you invent) to exit the dialog/window. Or, for a stacked widget, you would typically have links down the lefthand side to allow navigation between pages. I don't know what else to say.

                                    "for ex. i saw somewhere if we click right button of the mouse then current page will be closed and it will take us to main menu page back and so on."

                                    You would have to implement that yourself, it doesn't come "out-of-the-box".

                                    If you really want more help on this, I suggest you clarify what you mean, because reading a post which talks about a "menu" being both a "dropdown" and a "page" makes it impossible (for me) to understand.

                                    1 Reply Last reply
                                    0
                                    • A Offline
                                      A Offline
                                      Ashutosh_Sachdeva
                                      wrote on last edited by
                                      #31

                                      @JonB
                                      Ok i will try to be more specific from next time.

                                      Now i have created a mouse event to close the current window. But now what where i got stuck is:

                                      Suppose you have three pages from first page you triigered to second page and from second page you triggered to third page and now you want to come back to second page from the third page. So how can you hide/close the current page only

                                      void Searchpage::mousePressEvent(QMouseEvent *event)
                                      {
                                      if(event->buttons()== Qt::RightButton)
                                      {
                                      hide();
                                      }
                                      }

                                      if i'm using the hide function its's hiding the all other pages.

                                      JonBJ 1 Reply Last reply
                                      0
                                      • A Ashutosh_Sachdeva

                                        @JonB
                                        Ok i will try to be more specific from next time.

                                        Now i have created a mouse event to close the current window. But now what where i got stuck is:

                                        Suppose you have three pages from first page you triigered to second page and from second page you triggered to third page and now you want to come back to second page from the third page. So how can you hide/close the current page only

                                        void Searchpage::mousePressEvent(QMouseEvent *event)
                                        {
                                        if(event->buttons()== Qt::RightButton)
                                        {
                                        hide();
                                        }
                                        }

                                        if i'm using the hide function its's hiding the all other pages.

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

                                        @Ashutosh_Sachdeva
                                        I don't know, you're presumably hiding the wrong page, or you need to reshow the second page (secondPage->show()), or whatever is necessary.

                                        Did you look at QStackedWidget? If you can use that it will be better than your potentially-ugly-and-complex list of hides & shows.

                                        1 Reply Last reply
                                        0
                                        • A Offline
                                          A Offline
                                          Ashutosh_Sachdeva
                                          wrote on last edited by
                                          #33

                                          @JonB

                                          Yes i have gone through the QStackWidget.

                                          And mouse event function is also working fine now .

                                          JonBJ 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