×
Namespaces

Variants
Actions

Implementing QTreeView in QComboBox using Qt- Part 1

From Nokia Developer Wiki
Jump to: navigation, search
Article Metadata
Tested with
Devices(s): Symbian emulator
Compatibility
Platform(s): Qt
Symbian
Article
Keywords: QComboBox,QTreeView,QFileSystemModel
Created: mind_freak (12 Jul 2009)
Last edited: hamishwillee (11 Oct 2012)

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.

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 using Qt- Part 2

This page was last modified on 11 October 2012, at 04:17.
121 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.

×