2015-09-28 51 views
1

結合在具有表構件我的應用程序的IM,通過使用樣式表我試圖改變標題邊框和電池背景colors.refer我下面的代碼,如何2不同的樣式表在QT

//to set cell background color as white 
tableWidget->setStyleSheet(" QTableWidget::item { border: 1px solid white; }"); 
//to set header background as white 
tableWidget->setStyleSheet("QHeaderView::section{background-color: black;color:white;border: 1px solid white;}"); 

現在我想在樣式表中結合。指導我如何將上面的兩個樣式表合併到一個樣式表中。

回答

0
//to set cell background color as white 
QString styleSheet = " QTableWidget::item { border: 1px solid white; }"; 
//to set header background as white 
styleSheet += "QHeaderView::section{background-color: black;color:white;border: 1px solid white;}"; 
tableWidget->setStyleSheet(stylesheet); 

但是,您可以將所有內容放在一行中,不需要將樣式表分成兩部分。

+0

奇妙的是它的工作正常,在我的左側表格中,序列號顯示爲每行1 2 3 4。如何隱藏,指導我解決這個問題也 – shivcena

+0

@sivanesan,http://stackoverflow.com/questions/2942951/how-to-remove-index-number-from-qtablewidget – SingerOfTheFall

+0

非常感謝你,我會接受再過5分鐘你的答案 – shivcena