Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Unsolved Inheriting directly from QDockWidget makes it so I can't place widgets in designer

    General and Desktop
    2
    5
    745
    Loading More Posts
    • 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.
    • Shadowblitz16
      Shadowblitz16 last edited by

      does anybody know why I can't place widgets on my QDockWidget when its the topmost parent?

      I have it the top most parent because I want it to be a custom widget and not a custom window.
      http://imgur.com/a/gl9lp

      1 Reply Last reply Reply Quote 0
      • Chris Kawa
        Chris Kawa Moderators last edited by

        QDockWidget has its own layout and you put a widget in it via the method setWidget. So in your case make the top most widget inherit a QWidget instead of QDockWidget and add it to the dock from code.

        1 Reply Last reply Reply Quote 0
        • Shadowblitz16
          Shadowblitz16 last edited by Shadowblitz16

          the top most widget is the TileMapWidget that inherits from DockWidget though.
          and I need it to be a DockWidget so that when I add it I can dock it.

          QDockWidget *MainWindow::loadDockWindow(Qt::DockWidgetArea dockArea, QDockWidget *widget)
          {
              if (widget == NULL) addDockWidget(dockArea, widget);
          
              if (!widget->isVisible())  widget->show();
              else widget->hide();
          
              return widget;
          }
          
          
          
          1 Reply Last reply Reply Quote 0
          • Chris Kawa
            Chris Kawa Moderators last edited by

            Well, for whatever reason your dockwidget .ui file is missing the contents widget. Either recreate it via wizard or just manually fix the file in text editor:

            <?xml version="1.0" encoding="UTF-8"?>
            <ui version="4.0">
               <class>TileMapWidget</class>
               <widget class="QDockWidget" name="TileMapWidget">
                  <widget class="QWidget" name="dockWidgetContents"/>
               </widget>
            </ui>
            
            1 Reply Last reply Reply Quote 2
            • Shadowblitz16
              Shadowblitz16 last edited by

              thankyou Chris Kawa.

              1 Reply Last reply Reply Quote 0
              • First post
                Last post