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. Can a Dock Widget set a View with a custom Model instead of a Widget?
Forum Updated to NodeBB v4.3 + New Features

Can a Dock Widget set a View with a custom Model instead of a Widget?

Scheduled Pinned Locked Moved Unsolved General and Desktop
3 Posts 2 Posters 313 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.
  • LoquatL Offline
    LoquatL Offline
    Loquat
    wrote on last edited by Loquat
    #1

    Hi there,

    How can I make a QDockWidget set a View (e.g. QListView) instead of a widget, like:
    dock->setWidget(view);

    I'd like to dock my QListView which uses my custom Model, i.e.

    QListView* view = new QListView;
    view->setModel(customModel);
    

    But then I cannot do:

    QDockWidget* dock = new QDockWidget(tr("My dock"), this);
    dock->setWidget(view);
    

    Thanks

    1 Reply Last reply
    0
    • Christian EhrlicherC Offline
      Christian EhrlicherC Offline
      Christian Ehrlicher
      Lifetime Qt Champion
      wrote on last edited by
      #2

      @Loquat said in Can a Dock Widget set a View with a custom Model instead of a Widget?:

      But then I cannot do:

      You can - QListView derives from QWidget. What's your compiler error?

      Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
      Visit the Qt Academy at https://academy.qt.io/catalog

      LoquatL 1 Reply Last reply
      2
      • Christian EhrlicherC Christian Ehrlicher

        @Loquat said in Can a Dock Widget set a View with a custom Model instead of a Widget?:

        But then I cannot do:

        You can - QListView derives from QWidget. What's your compiler error?

        LoquatL Offline
        LoquatL Offline
        Loquat
        wrote on last edited by Loquat
        #3

        @Christian-Ehrlicher oh so it does but in a very long chain of inheritance... I thought it derived only from QAbstractItemView but then I didn't realise the chain is QListView:QAbstractItemView:QAbstractScrollArea:QFrame:QWidget

        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