Results 1 to 5 of 5

Thread: How to change default QTabWidget close button's tooltip text

  1. #1
    Join Date
    Jun 2009
    Location
    Kraków, Poland
    Posts
    23
    Thanks
    4
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60

    Default How to change default QTabWidget close button's tooltip text

    Hello, simple question:
    How can I change the default QTabWidget close button's tooltip text ("Close tab")?
    I would like to avoid using Qt Linguist, if it's a solution.

    And btw: Happy Easter!

  2. #2
    Join Date
    Sep 2009
    Location
    Finland
    Posts
    63
    Thanks
    1
    Thanked 22 Times in 19 Posts
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows Symbian S60

    Default Re: How to change default QTabWidget close button's tooltip text

    At first I thought that why don't you use QTabWidget::setTabToolTip but then I read your question again and I realised that you want to change the "Close Tab" text to something else. I did not find API method for that functionality and because of that I made a quick-and-dirty "workaround" and I tested it with my own application and it seems that it does the trick i.e. changes the text "Close Tab" to whatever you have defined. Here is my piece of code:

    Qt Code:
    1. // "tabs" is an instance of QTabWidget
    2. QList<QAbstractButton*> allPButtons = tabs->findChildren<QAbstractButton*>();
    3. for (int ind = 0; ind < allPButtons.size(); ind++) {
    4. QAbstractButton* item = allPButtons.at(ind);
    5. if (item->inherits("CloseButton"))
    6. item->setToolTip("Sulje"); // Default "Close Tab"
    7. }
    To copy to clipboard, switch view to plain text mode 

    There are also other buttons like QTableCornerButton and QToolButton inside of QTabWidget that is the reason to go through the whole list and select the ones that are inherits "CloseButton".

    Please note that the code above is using internals of the Qt and because of that might not be portable, I tested it with Ubuntu 9.10 where it worked as expected.

  3. The following user says thank you to tsp for this useful post:

    Fenix Voltres (6th April 2010)

  4. #3
    Join Date
    Jun 2009
    Location
    Kraków, Poland
    Posts
    23
    Thanks
    4
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60

    Default Re: How to change default QTabWidget close button's tooltip text

    Would be great to try yout method, but it seems you forgot to paste it in :P
    At least I don't see any piece of code
    If there's some modification in Qt source - no problem, in fact I did some other mods already, I just couldn't find exactly what to modify :>

  5. #4
    Join Date
    Sep 2009
    Location
    Finland
    Posts
    63
    Thanks
    1
    Thanked 22 Times in 19 Posts
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows Symbian S60

    Default Re: How to change default QTabWidget close button's tooltip text

    No I did not forget it, it is still there! It seems that as part of moving Qt Centre to new host (?), code with CODE tags is not visible at least in Firefox

    You can see the message with the code when you select "Reply" and then "Go Advanced" ...

  6. #5
    Join Date
    Jun 2009
    Location
    Kraków, Poland
    Posts
    23
    Thanks
    4
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60

    Default Re: How to change default QTabWidget close button's tooltip text

    You're absolutely right, something's wrong with FF, indeed.
    Thatnks much for code, works great, I'll try to access QTabWidget buttons which are responsible for scrolling tabs also.

Similar Threads

  1. How to add close button to each tab widget Qtabwidget?
    By kishore7771 in forum Qt Programming
    Replies: 3
    Last Post: 4th April 2010, 09:42
  2. How to change default clipping?
    By swbluto in forum Qt Programming
    Replies: 2
    Last Post: 29th October 2009, 19:35
  3. How to change default manifest file?
    By piotr.dobrogost in forum General Programming
    Replies: 1
    Last Post: 22nd July 2009, 09:53
  4. Disable close button on QTabWidget/QTabBar
    By minimoog in forum Qt Programming
    Replies: 1
    Last Post: 16th March 2009, 06:25
  5. QTabWidget: how to close a tab by a click
    By YaK in forum Qt Programming
    Replies: 3
    Last Post: 1st December 2008, 19:10

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.