Results 1 to 5 of 5

Thread: [Qt] QTabWidget problem with change text style on tabs.

  1. #1
    Join Date
    Dec 2009
    Posts
    23
    Thanks
    8
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default [Qt] QTabWidget problem with change text style on tabs.

    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

  2. #2
    Join Date
    Dec 2009
    Posts
    23
    Thanks
    8
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: [Qt] QTabWidget problem with change text style on tabs.

    Can somebody help me?

  3. #3
    Join Date
    Oct 2009
    Posts
    28
    Thanks
    4
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: [Qt] QTabWidget problem with change text style on tabs.

    Hello Xandareva.
    With this:
    Qt Code:
    1. QString style = "QTabBar::tab:selected {";
    2. style.append(QString("background:")).append(QColor(Qt::yellow).name() + ";");
    3. tabWidget->tabBar()->setStyleSheet(style);
    To copy to clipboard, switch view to plain text mode 

    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

  4. #4
    Join Date
    Dec 2009
    Posts
    23
    Thanks
    8
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: [Qt] QTabWidget problem with change text style on tabs.

    ‘QTabBar* QTabWidget::tabBar() const’ is protected
    Any ideas?

  5. #5
    Join Date
    Oct 2009
    Posts
    28
    Thanks
    4
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: [Qt] QTabWidget problem with change text style on tabs.

    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;

    Qt Code:
    1. class CTabWidget : public QTabWidget
    2. {
    3. public:
    4. CTabWidget(QWidget *parent =0);
    5. virtual ~CTabWidget();
    6.  
    7. QTabBar* tabBar() const { return (QTabWidget::tabBar());}
    8. };
    To copy to clipboard, switch view to plain text mode 

Similar Threads

  1. QTabWidget with same tabs
    By Djony in forum Qt Programming
    Replies: 20
    Last Post: 24th December 2011, 13:20
  2. Replies: 4
    Last Post: 6th April 2010, 01:46
  3. Replies: 1
    Last Post: 27th February 2010, 12:39
  4. How to change the style of QTabWidget
    By iamjayanth in forum Qt Programming
    Replies: 1
    Last Post: 24th April 2009, 13:07
  5. Switching off all tabs in QTabWidget
    By Gopala Krishna in forum Qt Programming
    Replies: 7
    Last Post: 30th August 2006, 18:10

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.