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. QMainWindow to QWidget

QMainWindow to QWidget

Scheduled Pinned Locked Moved Unsolved General and Desktop
15 Posts 4 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.
  • V Offline
    V Offline
    VJain85
    wrote on last edited by
    #1

    Hello everyone!
    Does anyone know if there is a way of converting QMainWindow class to QWidget class?
    Or not, then what necessary changes will I have to make to do the same?

    J.HilkJ 1 Reply Last reply
    0
    • V VJain85

      Hello everyone!
      Does anyone know if there is a way of converting QMainWindow class to QWidget class?
      Or not, then what necessary changes will I have to make to do the same?

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

      @VJain85
      where do you want to change it ?
      Is it a designer only element or is it the base class of one of your classes ?


      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
      • V Offline
        V Offline
        VJain85
        wrote on last edited by
        #3

        It is a base class of the class named "WinMain" . Now I want to make "WinMain" as a widget instead of main window so that it can be integrated in some other project.

        jsulmJ 1 Reply Last reply
        0
        • V VJain85

          It is a base class of the class named "WinMain" . Now I want to make "WinMain" as a widget instead of main window so that it can be integrated in some other project.

          jsulmJ Offline
          jsulmJ Offline
          jsulm
          Lifetime Qt Champion
          wrote on last edited by
          #4

          @VJain85 said in QMainWindow to QWidget:

          WinMain

          Simply inherit QWidget instead of QMainWindow in WinMain

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

          1 Reply Last reply
          2
          • V Offline
            V Offline
            VJain85
            wrote on last edited by
            #5

            I tried that thing. But the main issue is it contains menu and title items. they are causing errors. they can't be included in widget.

            mrjjM 1 Reply Last reply
            0
            • V VJain85

              I tried that thing. But the main issue is it contains menu and title items. they are causing errors. they can't be included in widget.

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

              @VJain85

              But if you want it to have toolbar and menus, why you then want it as a QWidget ????

              Also can you explain the use case since QMainWindow is already a QWidget and can be used as a QWidget
              in any/most regards, like inserting into dialogs etc.

              So Why do you need this ?

              A project can have many MainWindows if you like. It does not matter.
              You can use it as a widget while being of type QMainWindow.

              1 Reply Last reply
              4
              • V Offline
                V Offline
                VJain85
                wrote on last edited by
                #7

                Actually I am making a paint app. The code that I have, it contains all the shape icons in the TitleBar, and i want one separate widget that contains shape icons in the left side and the second is the drawable area in the right side.

                mrjjM 1 Reply Last reply
                0
                • V VJain85

                  Actually I am making a paint app. The code that I have, it contains all the shape icons in the TitleBar, and i want one separate widget that contains shape icons in the left side and the second is the drawable area in the right side.

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

                  @VJain85

                  Ok so all the icon code in current MainWindow need to move to another class and
                  that is why you want to convert the base to plain QWidget ?

                  Else I would just ignore that its of type QMainWindow and rename it to
                  something else and just use it like any other QWidget.

                  1 Reply Last reply
                  1
                  • V Offline
                    V Offline
                    VJain85
                    wrote on last edited by
                    #9

                    Yes this time you got me right. So what is the best way of doing that?

                    mrjjM 1 Reply Last reply
                    0
                    • V VJain85

                      Yes this time you got me right. So what is the best way of doing that?

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

                      @VJain85

                      Which of the options ?

                      • Remove all icon and non compiling code
                        That is simply just to do it. Manually.
                        Maybe its easier to take the code you want for widget and put in new QWidget and then trow out the MainWin

                      • Use it as QWidget ?
                        Just do it. Its also a Qwidget besides a QMainWin so its just to do it.

                      1 Reply Last reply
                      1
                      • V Offline
                        V Offline
                        VJain85
                        wrote on last edited by
                        #11

                        Thanks for your suggestions. I think I should make a new file for QWidget and move the code to it.

                        mrjjM 1 Reply Last reply
                        0
                        • V VJain85

                          Thanks for your suggestions. I think I should make a new file for QWidget and move the code to it.

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

                          @VJain85
                          Yes I would do like that instead of
                          chopping the old Mainwindow up.
                          As its easier to find out what wrong if something breaks when you have the original MainWind to look at.

                          So what kind of drawing app is it ? :)

                          1 Reply Last reply
                          1
                          • V Offline
                            V Offline
                            VJain85
                            wrote on last edited by
                            #13

                            It is a schematic capture used for making schematic diagrams for circuits.

                            mrjjM 1 Reply Last reply
                            0
                            • V VJain85

                              It is a schematic capture used for making schematic diagrams for circuits.

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

                              @VJain85

                              Ok that sounds exciting. And slightly big project :) good luck.

                              Just as a note, a friend of mine made this great library
                              https://forum.qt.io/topic/104100/diagram-schematic-components-library
                              if you need inspiration/just to check out.

                              1 Reply Last reply
                              2
                              • V Offline
                                V Offline
                                VJain85
                                wrote on last edited by
                                #15

                                Yes it seems a big project. BTW thanks alot for the help :) .

                                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