i want to create a listview as the attachement,but i can't find any sample code ,could any one can help me
未命名..jpg
 Intermediate user
					
					
						Intermediate user
					
					
                                        
					
						
							
								 
							
						
					
					
						 
    
    
    
    
    
    
   
    
    
    
    
   I want to create a form with QListView
 I want to create a form with QListView
		i want to create a listview as the attachement,but i can't find any sample code ,could any one can help me
未命名..jpg
 Re: I want to create a form with QListView
 Re: I want to create a form with QListView
		Have a look at QListView::setViewModeJust play in designer a little.
 Intermediate user
					
					
						Intermediate user
					
					
                                        
					
						
							
								 
							
						
					
					
						 
    
    
    
    
    
    
   
    
    
    
    
   Re: I want to create a form with QListView
 Re: I want to create a form with QListView
		i can't get how to use it ,can you give me some sample code from the beginning to end ,thank you
 Intermediate user
					
					
						Intermediate user
					
					
                                        
					
						
							
								 
							
						
					
					
						 
    
    
    
    
    
    
   
    
    
    
    
    
   Re: I want to create a form with QListView
 Re: I want to create a form with QListView
		Qt Code:
#include <QtGui>
int main(int argc, char * argv[])
{
model->setData(model->index(0, 0), lv->style()->standardIcon(QStyle::SP_BrowserReload), Qt::DecorationRole);
model->setData(model->index(0, 0), "Hello World!", Qt::DisplayRole);
model->setData(model->index(1, 0), lv->style()->standardIcon(QStyle::SP_FileIcon), Qt::DecorationRole);
model->setData(model->index(1, 0), "Goodbye World!", Qt::DisplayRole);
lv->setModel(model);
lv->show();
return a.exec();
}To copy to clipboard, switch view to plain text mode
xiongxiongchuan (3rd June 2010)
 Intermediate user
					
					
						Intermediate user
					
					
                                        
					
						
							
								 
							
						
					
					
						 
    
    
    
    
    
    
   
    
    
    
    
   Re: I want to create a form with QListView
 Re: I want to create a form with QListView
		Thanks ,you are so kind ,but when i do this as you taught me ,and i found the lable is editable ,how to set the label is not allowed to be edited;
 Expert
					
					
						Expert
					
					
                                        
					
						
							
								 
							
								 
							
								 
							
								 
							
								 
							
								 
							
						
					
					
						 
    
    
    
    
    
    
   
    
    
       
    
    
    
    
   Re: I want to create a form with QListView
 Re: I want to create a form with QListView
		Ohh come one, read the documentation
http://doc.qt.nokia.com/4.6/index.html
 Intermediate user
					
					
						Intermediate user
					
					
                                        
					
						
							
								 
							
						
					
					
						 
    
    
    
    
    
    
   
    
    
    
    
   Re: I want to create a form with QListView
 Re: I want to create a form with QListView
		i have looked up for this problem in the QT Document ,but i can't find any solutions ,plz help me
 Expert
					
					
						Expert
					
					
                                        
					
						
							
								 
							
								 
							
								 
							
								 
							
								 
							
								 
							
						
					
					
						 
    
    
    
    
    
    
   
    
    
       
    
    
    
    
   Re: I want to create a form with QListView
 Re: I want to create a form with QListView
		What label?
 Intermediate user
					
					
						Intermediate user
					
					
                                        
					
						
							
								 
							
						
					
					
						 
    
    
    
    
    
    
   
    
    
    
    
    
   Re: I want to create a form with QListView
 Re: I want to create a form with QListView
		You have to set the item flags, as needed:
Qt Code:
model->item(0,0)->setFlags(Qt::ItemIsEnabled | Qt::ItemIsSelectable);To copy to clipboard, switch view to plain text mode
 Intermediate user
					
					
						Intermediate user
					
					
                                        
					
						
							
								 
							
						
					
					
						 
    
    
    
    
    
    
   
    
    
    
    
   Re: I want to create a form with QListView
 Re: I want to create a form with QListView
		i set the lable model as this below ,however ,the lable still can be edit,i can't find any properties to stop this!
when i double clicked the item ,the lable can be renamed
Qt Code:
model->setData(model->index(0,0),tr("This is input well data file"),Qt::WhatsThisRole| Qt::ItemIsEditable);To copy to clipboard, switch view to plain text mode
Last edited by xiongxiongchuan; 5th June 2010 at 13:50.
 Re: I want to create a form with QListView
 Re: I want to create a form with QListView
		If you dont want the item editable, shouldnt you be using NOT of Qt::ItemIsEditable ( ~Qt::ItemIsEditable)
 Intermediate user
					
					
						Intermediate user
					
					
                                        
					
						
							
								 
							
						
					
					
						 
    
    
    
    
    
    
   
    
    
    
    
   Re: I want to create a form with QListView
 Re: I want to create a form with QListView
		i using the code as this ,however,it did't display the lable ,and still can be editedQt Code:
model->setData(model->index(0, 0), tr("Well Data"), Qt::DisplayRole|~Qt::ItemIsEditable);To copy to clipboard, switch view to plain text mode

 Advanced user
					
					
						Advanced user
					
					
                                        
					
						
							
								 
							
								 
							
						
					
					
						 
    
    
       
    
    
    
    
    
   
    
    
       
    
    
    
    
   Re: I want to create a form with QListView
 Re: I want to create a form with QListView
		You have to set flags, not data.
Ginsengelf
 Re: I want to create a form with QListView
 Re: I want to create a form with QListView
		As far as I remember, I guess the flags are stored in standard item with (Qt::UserRole - 1)
 Intermediate user
					
					
						Intermediate user
					
					
                                        
					
						
							
								 
							
						
					
					
						 
    
    
    
    
    
    
   
    
    
    
    
   Re: I want to create a form with QListView
 Re: I want to create a form with QListView
		could you give me some more details ,thanks !
 Intermediate user
					
					
						Intermediate user
					
					
                                        
					
						
							
								 
							
						
					
					
						 
    
    
    
    
    
    
   
    
    
       
    
    
    
    
   Re: I want to create a form with QListView
 Re: I want to create a form with QListView
		try this code:
Qt Code:
To copy to clipboard, switch view to plain text mode
Bookmarks