How can I set a background pixmap in a cell of QTableWidget?
in QT3 , there is a
Qt Code:
To copy to clipboard, switch view to plain text mode
If I change the QTable to QTableWidget, how can I complete the above task?
 Intermediate user
					
					
						Intermediate user
					
					
                                        
					
						
							
								 
							
						
					
					
						 
    
    
       
    
    
    
    
    
    
   QTableWidget Pixmap problem
 QTableWidget Pixmap problem
		How can I set a background pixmap in a cell of QTableWidget?
in QT3 , there is a
Qt Code:
To copy to clipboard, switch view to plain text mode
If I change the QTable to QTableWidget, how can I complete the above task?
 Guru
					
					
						Guru
					
					
                                        
					
						
							
								 
							
						
					
					
						 
    
    
       
    
    
    
    
    
    
   
    
    
       
    
    
    
    
   Re: QTableWidget Pixmap problem
 Re: QTableWidget Pixmap problem
		There are methods for setting a background texture or an icon, but I don't think you want that. You can subclass QTableWidgetItem and make it paint the pixmap.
 Re: QTableWidget Pixmap problem
 Re: QTableWidget Pixmap problem
		Maybe its possible to use the following function on a QTableWidget:
Returns the item for the given row and column if one has been set; otherwise returns 0.Qt Code:
To copy to clipboard, switch view to plain text mode
after you got the QTableWidgetItem, use this function on it:
Sets the item's icon to the icon specified.Qt Code:
To copy to clipboard, switch view to plain text mode
ah by the way a QIcon can be created from a pixmap using the following constructor:
Qt Code:
To copy to clipboard, switch view to plain text mode
Correct me if i am wrong, i am currently not working with Qt4, but i remember i did something like this in the past
Last edited by BrainB0ne; 5th September 2008 at 09:45.
..:: Still Standing Strong ::..
 Beginner
					
					
						Beginner
					
					
                                        
					
						
							
								 
							
						
					
					
						 
    
    
    
    
    
   
    
    
    
    
   Re: QTableWidget Pixmap problem
 Re: QTableWidget Pixmap problem
		Use setData with Qt:: DecorationRole instead, to display an entire picture.
Qt Code:
newItem->setData(Qt::DecorationRole, pixmap);
m_verticalRoadSignWidget->ui.mruTableWidget->setItem(0, 0, newItem);To copy to clipboard, switch view to plain text mode
Bookmarks