How to hide this function?
-
http://xiangce.baidu.com/picture/detail/1f3b7ef22e7b961d23a7390158e9f34bc1789ceb
QTablewidget has a function,when selecte a row ,this row has a color that is diffenernt from other rows. how to hide this function?i span two rows' some items,for instance item(0,0),item(0,1),
item(1,0),item(1,1) by setSpan( 0 , 0, 2, 1 ).the rest item, all up item ,i set a font and color , all down item ,i set a font and color ,now i want to keep up and down item's font and color,
but when i use stylesheet
QTableWidget::item:selected{selection-background-color: rgb(62,86,112);selection-color: rgb(255,0,0);}"the up and down item's font and color are changed.
-
Hi and welcome to devnet,
Do you mean that you don't want the selection feedback ?
-
i span two rows’ some items,for instance item(0,0),item(0,1),
item(1,0),item(1,1) by setSpan( 0 , 0, 2, 1 ).the rest item, all up item ,i set a font and color , all down item ,i set a font and color ,now i want to keep up and down item’s font and color,
but when i use stylesheet
QTableWidget::item:selected{selection-background-color: rgb(62,86,112);selection-color: rgb(255,0,0);}”the up and down item’s font and color are changed.
-
Could you post images of what is happening ?
I'm not sure I am following you right
-
http://xiangce.baidu.com/picture/detail/1f3b7ef22e7b961d23a7390158e9f34bc1789ceb
it's my image,thank you.
-
I think I'm starting to understand, could post a little code example that reproduce the behavior you are getting ?
-
@initAItemUpData( QVector<QString> Info, QString Align, QFont upFort, QColor upcolor,int index)
{int textAlign = ConvertNameToIndex( Align ); for( int i = 0,j = 0; i < m_cellRow && j < Info.count(); i++ ) { if( i %3 == 0 ) { this->setItem(i, index, new QTableWidgetItem(Info.at(j))); if( AlignLeft == textAlign ) { this->item(i, index)->setTextAlignment(Qt::AlignLeft); } else if( AlignCenter == textAlign ) { this->item(i, index)->setTextAlignment(Qt::AlignCenter); } else if( AlignRight == textAlign ) { this->item(i, index)->setTextAlignment(Qt::AlignRight); } this->item(i, index)->setFont(upFort); this->item(i, index)->setTextColor(upcolor); j++; } }
}
initAItemDownData( QVector<QString> Info, QString Align, QFont downFort, QColor downcolor,int index )
{int textAlign = ConvertNameToIndex( Align ); for( int i = 0,j = 0; i < m_cellRow && j < Info.count(); i++ ) { if(i %3 == 1 ) { this->setItem(i, index, new QTableWidgetItem(Info.at(j))); if( AlignLeft == textAlign ) { this->item(i, index)->setTextAlignment(Qt::AlignLeft); } else if( AlignCenter == textAlign ) { this->item(i, index)->setTextAlignment(Qt::AlignCenter); } else if( AlignRight == textAlign ) { this->item(i, index)->setTextAlignment(Qt::AlignRight); } this->item(i, index)->setFont(downFort); this->item(i, index)->setTextColor(downcolor); j++; } }
}@
-
Hello,
What do you exactly mean by you want to "hide this function"?
Please elaborate "hide this function" exactly.
Are you stating that you would like to not have that function?
or
Are you trying to change the function so that you can use the stylesheet to color the textareas as you prefer? -
I use stylesheet to change tablewidget's color . i set item's font and font's color,but when i selected a row ,font's color is change,it's not original's color that i set.this 'is my image;
http://xiangce.baidu.com/picture/detail/1f3b7ef22e7b961d23a7390158e9f34bc1789ceb
now ,my one row is two rows,i span two rows to one row. -
Correct me if I am wrong, would you like to use stylesheets or internally change the functions in C++ to color the text?
-
may be my english is not well, i want to set color when i selecte one row.so ,i use stylesheets ,for instance,
@QTableWidget::item:selected{selection-background-color: rgb(53,96,138);
@
but one qustion appear,i have setted item's text color in one row,but my one row is not real one row , i span (0,0,2,1) in two rows.when i use stylesheets to set selecte one row's color,the item's text color can be change,for intance , the original item's text color is red ,when i cliked one row ,item's text color is not red .
please see my tablewidget's image.the web address is :
http://xiangce.baidu.com/picture/detail/1f3b7ef22e7b961d23a7390158e9f34bc1789ceb
you can see my original's item's text color and selected item's text color .
how to do it that when i selecte one row,the item's text color is the same with original's item's text color that i setted.
thank you