Namespaces

Variants
Actions

Please note that as of October 24, 2014, the Nokia Developer Wiki will no longer be accepting user contributions, including new entries, edits and comments, as we begin transitioning to our new home, in the Windows Phone Development Wiki. We plan to move over the majority of the existing entries over the next few weeks. Thanks for all your past and future contributions.

Revision as of 03:20, 16 September 2009 by fasttrack (Talk | contribs)

Implementing QTreeView in QComboBox using Qt- Part 1

From Wiki
Jump to: navigation, search
{{{width}}}
Article Metadata
Tested with
Devices(s): Emulator
Compatibility
Platform(s): S60 3rd Edition, FP1, FP2
S60 5th Edition
Symbian
Article
Keywords: QComboBox,QTreeView,QFileSystemModel
Created: (12 Jul 2009)
Last edited: fasttrack (16 Sep 2009)

Contents

Introduction

Here is the code snippet for the treeview implemented in combobox.In this their is file model object defined that has been set in the combobox(ui->comboBox->setModel(fsmodel);).we can navigate to the different directories by just opening the combox and selecting item.

Preconditions

Source Code

    QFileSystemModel *fsmodel = new QFileSystemModel(this);
fsmodel->setRootPath("/");
setStyleSheet("* { background-color:rgb(90,20,60);color:rgb(255,255,255); padding: 7px}}");
QTreeView *tv = new QTreeView(ui->comboBox);
ui->comboBox->setStyleSheet("* { background-color:rgb(225,225,225);color:rgb(255,255,255); padding: 7px}}");
ui->comboBox->setView(tv);
ui->comboBox->setModel(fsmodel);

Screenshot

Treecombo.JPG


Problem

Given code snippet works fully,but their is a problem regarding the popup of the comboBox.As we click to expand the tree the comboBox popup closes,so we are not able to select the preferred item form the treeView at a time,number of clicks are to be made to select the preferred item.

Solution

For the solution of upper given problem visit:Implementing QTreeView in QComboBox-II

371 page views in the last 30 days.

Was this page helpful?

Your feedback about this content is important. Let us know what you think.

 

Thank you!

We appreciate your feedback.

×