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. Converting between QMainWindow/QWidget/QDialog in QtDesigner

Converting between QMainWindow/QWidget/QDialog in QtDesigner

Scheduled Pinned Locked Moved General and Desktop
7 Posts 5 Posters 26.5k 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.
  • D Offline
    D Offline
    daviddoria
    wrote on last edited by
    #1

    Is it possible to convert between these types of widgets in the designer? Say I have a QMainWindow in QtDesigner and now I'd rather it be a QDialog - is there a way to convert this to a QWidget without copying/pasting all of the subwidgets?

    Thanks,

    David

    1 Reply Last reply
    0
    • S Offline
      S Offline
      shoyeb
      wrote on last edited by
      #2

      u can try one thing,

      just right click on the widget which u want to convert and then select morph into option and this will give u option to covert ur widget into another widget...

      There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code.

      1 Reply Last reply
      0
      • D Offline
        D Offline
        daviddoria
        wrote on last edited by
        #3

        When I right click on a QMainWindow, I don't see any "morph" option.

        1 Reply Last reply
        0
        • JeroentjehomeJ Offline
          JeroentjehomeJ Offline
          Jeroentjehome
          wrote on last edited by
          #4

          You might want to try to edit the xml file that designer is. When opened design, click on Edit and there in the first couple of lines are the QMainWindow class and name.
          Would try it there. Couldn't find it in Designer myself.
          greetz

          Greetz, Jeroen

          D 1 Reply Last reply
          0
          • ? This user is from outside of this forum
            ? This user is from outside of this forum
            Guest
            wrote on last edited by
            #5

            @daviddoria

            In QMainWindow morph does not work, but the widget will support

            1 Reply Last reply
            0
            • Aleksey_KA Offline
              Aleksey_KA Offline
              Aleksey_K
              wrote on last edited by
              #6

              You need to manually edit ui file outside Qt Designer and replace QMainWindow to QDialog. Then remove <widget class="QWidget" name="centralwidget"> element and correspondent closing tag. Then fix cpp/h accordingly.

              1 Reply Last reply
              0
              • JeroentjehomeJ Jeroentjehome

                You might want to try to edit the xml file that designer is. When opened design, click on Edit and there in the first couple of lines are the QMainWindow class and name.
                Would try it there. Couldn't find it in Designer myself.
                greetz

                D Offline
                D Offline
                Dwende
                wrote on last edited by
                #7

                @Jeroentjehome

                I just had to do this (QT 6.3)

                Edit the UI -> replace QMainWindow with QWidget.

                Same for Class CPP & UI ...

                My issue was I need to keep a constant "main menu" - I then found that my recently converted QWidget form had menu in the XML definition.

                I cut this out, clean,qmake and run ... now I have a constant main-menu.

                Easy fix - thanks to you starting me out in the right direction.

                Tim

                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