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. Inheriting directly from QDockWidget makes it so I can't place widgets in designer

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

Scheduled Pinned Locked Moved Unsolved General and Desktop
5 Posts 2 Posters 1.0k 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.
  • Shadowblitz16S Offline
    Shadowblitz16S Offline
    Shadowblitz16
    wrote on last edited by
    #1

    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
    0
    • Chris KawaC Offline
      Chris KawaC Offline
      Chris Kawa
      Lifetime Qt Champion
      wrote on last edited by
      #2

      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
      0
      • Shadowblitz16S Offline
        Shadowblitz16S Offline
        Shadowblitz16
        wrote on last edited by Shadowblitz16
        #3

        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
        0
        • Chris KawaC Offline
          Chris KawaC Offline
          Chris Kawa
          Lifetime Qt Champion
          wrote on last edited by
          #4

          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
          2
          • Shadowblitz16S Offline
            Shadowblitz16S Offline
            Shadowblitz16
            wrote on last edited by
            #5

            thankyou Chris Kawa.

            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