PDA

View Full Version : [Qt] QTabWidget problem with change text style on tabs.



Xandareva
24th July 2010, 07:33
Hello,
I have got a small problem, I am creating Chat with client and server, now I have implemented PrivateMessage system. Window's message client looks like:

Messages | User #1 | User #2

If somebody sent to me message, client create new tab (tabWidget->addTab(...)), all is ok but I don't know how to notify user whom recived message. I have idea, I would like to change font style (set bold) tab text in which is new unread messages. So how can I do that?

Thanks for replies

Xandareva
26th July 2010, 09:47
Can somebody help me?

gutiory
27th July 2010, 06:56
Hello Xandareva.
With this:

QString style = "QTabBar::tab:selected {";
style.append(QString("background:")).append(QColor(Qt::yellow).name() + ";");
tabWidget->tabBar()->setStyleSheet(style);

You can change the background color of the tab when is selected to yellow color.
So using css, I think you could change the color or the size of the text.

Try this for undestanding css if you don't know:

http://www.w3schools.com/css/pr_font_font.asp

I hope that helps.
Regards

Xandareva
27th July 2010, 14:17
‘QTabBar* QTabWidget::tabBar() const’ is protected

Any ideas?

gutiory
28th July 2010, 09:57
Sorry, it was my fault.
I forgot to say to you that the tabWidget is an object from an own class that inherits from QTabWidget and has a method which returns the tabBar;


class CTabWidget : public QTabWidget
{
public:
CTabWidget(QWidget *parent =0);
virtual ~CTabWidget();

QTabBar* tabBar() const { return (QTabWidget::tabBar());}
};