Results 1 to 4 of 4

Thread: QComboBox listview in separate dialog

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Feb 2011
    Location
    Bangalore
    Posts
    207
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Thanks
    20
    Thanked 28 Times in 27 Posts

    Default Re: QComboBox listview in separate dialog

    QComboBox::model(). Use it to get the model and have a independent QListView in your dialog. Set the model of this QListView to the model from QCombobox.

  2. #2
    Join Date
    Aug 2011
    Posts
    5
    Qt products
    Qt4
    Platforms
    Windows Android

    Default Re: QComboBox listview in separate dialog

    Thanks for the hint.
    I tried changing the dialog constructor to this:

    Qt Code:
    1. ComboList::ComboList(QWidget *parent, QAbstractItemModel *pListModel, QString strTitle):
    2. DialogExt(parent)
    To copy to clipboard, switch view to plain text mode 

    And set up the model like this:
    Qt Code:
    1. m_pList = new QListView(this);
    2. m_pList->setModel(pListModel);
    To copy to clipboard, switch view to plain text mode 

    This however gives the same result as initially. The dialog view is populated correctly, but the selected item is not set in the dialog list. And when selecting something here, the original combobox does not show the changed item.

  3. #3
    Join Date
    Feb 2011
    Location
    Bangalore
    Posts
    207
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Thanks
    20
    Thanked 28 Times in 27 Posts

    Default Re: QComboBox listview in separate dialog

    If you need the selected items to be in sync then you need to share the selection model. A selection model belonging to one view can be obtained using the view's selectionModel() function, and shared between many views with setSelectionModel().
    Get QComboBox::view()::selectionModel(). Then QListView::setSelectionModel(...)

Similar Threads

  1. How to access objects of parent Dialog from Child Dialog .
    By ranjit.kadam in forum Qt Programming
    Replies: 4
    Last Post: 18th April 2011, 06:39
  2. How to load items in QComboBox in a separate thread?
    By Rufone in forum Qt Programming
    Replies: 3
    Last Post: 21st February 2011, 13:33
  3. Replies: 0
    Last Post: 19th August 2010, 17:07
  4. closing child dialog closes parent dialog
    By sparticus_37 in forum Newbie
    Replies: 2
    Last Post: 28th May 2010, 19:46
  5. separate a QString
    By Zergi in forum Newbie
    Replies: 1
    Last Post: 18th July 2008, 21:50

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.