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. controls from ui design not showing up when program runs

controls from ui design not showing up when program runs

Scheduled Pinned Locked Moved Solved General and Desktop
5 Posts 3 Posters 317 Views
  • 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.
  • Q Offline
    Q Offline
    qtForumsUser5
    wrote on 31 May 2023, 13:07 last edited by
    #1

    I made a UI design for a QDialog box with a bunch of controls, but when I run it it shows a blank frame, all the controls are missing. I changed the base class of the widget from a QMainWindow to a QDialog after the initial design, maybe it's something to do with that? Any idea why the controls aren't showing up?

    f1.JPG

    f2.JPG

    C J 2 Replies Last reply 31 May 2023, 14:15
    0
    • Q qtForumsUser5
      31 May 2023, 13:07

      I made a UI design for a QDialog box with a bunch of controls, but when I run it it shows a blank frame, all the controls are missing. I changed the base class of the widget from a QMainWindow to a QDialog after the initial design, maybe it's something to do with that? Any idea why the controls aren't showing up?

      f1.JPG

      f2.JPG

      J Offline
      J Offline
      JonB
      wrote on 31 May 2023, 14:15 last edited by JonB
      #3

      @qtForumsUser5 said in controls from ui design not showing up when program runs:

      I changed the base class of the widget from a QMainWindow to a QDialog after the initial design, maybe it's something to do with that?

      Who knows, maybe, depends what you did.

      Your current Object Explorer at the right shows:

      • Your top-level QDialog does not have any layout (the "red no-entry" sign). That is wrong.
      • It has a child named centralWidget which is also of type QDialog. This is wrong. centralWidget is a QWidget for QMainWindow only, and a QDialog should not have a QDialog as a child.
      C Q 2 Replies Last reply 31 May 2023, 14:18
      3
      • Q qtForumsUser5
        31 May 2023, 13:07

        I made a UI design for a QDialog box with a bunch of controls, but when I run it it shows a blank frame, all the controls are missing. I changed the base class of the widget from a QMainWindow to a QDialog after the initial design, maybe it's something to do with that? Any idea why the controls aren't showing up?

        f1.JPG

        f2.JPG

        C Offline
        C Offline
        CPPUIX
        wrote on 31 May 2023, 14:15 last edited by
        #2

        Hi,

        @qtForumsUser5 said in controls from ui design not showing up when program runs:

        I changed the base class of the widget from a QMainWindow to a QDialog after the initial design, maybe it's something to do with that?

        Yes, exactly, try ui->centralwidget->setVisible(true); in your addSensor ctor, your controls will appear in a separate window, which is a QDialog.

        Why did you make a project with QMainWindow, and then changed it to QDialog? And how did you change it?

        1 Reply Last reply
        0
        • Q qtForumsUser5
          31 May 2023, 13:07

          I made a UI design for a QDialog box with a bunch of controls, but when I run it it shows a blank frame, all the controls are missing. I changed the base class of the widget from a QMainWindow to a QDialog after the initial design, maybe it's something to do with that? Any idea why the controls aren't showing up?

          f1.JPG

          f2.JPG

          J Offline
          J Offline
          JonB
          wrote on 31 May 2023, 14:15 last edited by JonB
          #3

          @qtForumsUser5 said in controls from ui design not showing up when program runs:

          I changed the base class of the widget from a QMainWindow to a QDialog after the initial design, maybe it's something to do with that?

          Who knows, maybe, depends what you did.

          Your current Object Explorer at the right shows:

          • Your top-level QDialog does not have any layout (the "red no-entry" sign). That is wrong.
          • It has a child named centralWidget which is also of type QDialog. This is wrong. centralWidget is a QWidget for QMainWindow only, and a QDialog should not have a QDialog as a child.
          C Q 2 Replies Last reply 31 May 2023, 14:18
          3
          • J JonB
            31 May 2023, 14:15

            @qtForumsUser5 said in controls from ui design not showing up when program runs:

            I changed the base class of the widget from a QMainWindow to a QDialog after the initial design, maybe it's something to do with that?

            Who knows, maybe, depends what you did.

            Your current Object Explorer at the right shows:

            • Your top-level QDialog does not have any layout (the "red no-entry" sign). That is wrong.
            • It has a child named centralWidget which is also of type QDialog. This is wrong. centralWidget is a QWidget for QMainWindow only, and a QDialog should not have a QDialog as a child.
            C Offline
            C Offline
            CPPUIX
            wrote on 31 May 2023, 14:18 last edited by
            #4

            @JonB said in controls from ui design not showing up when program runs:

            a QDialog should not have a QDialog as a child.

            So that's why ui->centralWidget->setParent(this); did not work when I tried it. Thanks for the clarification.

            1 Reply Last reply
            0
            • J JonB
              31 May 2023, 14:15

              @qtForumsUser5 said in controls from ui design not showing up when program runs:

              I changed the base class of the widget from a QMainWindow to a QDialog after the initial design, maybe it's something to do with that?

              Who knows, maybe, depends what you did.

              Your current Object Explorer at the right shows:

              • Your top-level QDialog does not have any layout (the "red no-entry" sign). That is wrong.
              • It has a child named centralWidget which is also of type QDialog. This is wrong. centralWidget is a QWidget for QMainWindow only, and a QDialog should not have a QDialog as a child.
              Q Offline
              Q Offline
              qtForumsUser5
              wrote on 31 May 2023, 16:25 last edited by
              #5
              • Your top-level QDialog does not have any layout (the "red no-entry" sign). That is wrong.
              • It has a child named centralWidget which is also of type QDialog. This is wrong. centralWidget is a QWidget for QMainWindow only, and a QDialog should not have a QDialog as a child.

              Ok, that was the problem. Wasn't aware the mainwindow widget functioned that way, I removed the centralwidget and it works now.

              Why did you make a project with QMainWindow, and then changed it to QDialog? And how did you change it?

              I made a new project with default settings to quickly prototype a ui design to add to another larger program without realizing I would need to change the base class of the widget. I changed it by editing the XML file <class> </class> tags.

              Appreciate the help, cheers.

              1 Reply Last reply
              1
              • Q qtForumsUser5 has marked this topic as solved on 31 May 2023, 16:26

              1/5

              31 May 2023, 13:07

              • Login

              • Login or register to search.
              1 out of 5
              • First post
                1/5
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • Users
              • Groups
              • Search
              • Get Qt Extensions
              • Unsolved