Results 1 to 5 of 5

Thread: Tooltip on QTableWidget header

  1. #1
    Join Date
    Nov 2006
    Location
    Dresden, Germany
    Posts
    108
    Thanks
    9
    Thanked 12 Times in 10 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Question Tooltip on QTableWidget header

    Hi there,

    is there an easy solution to get tooltips when hovering over headers in QTableWidget or QTableView widgets?

    My solution would be a combination of QHelpEvent and some coordinate calculation using indexOf() in the QHeaderView to find the correct header/column, but this looks to complicated...

    Thanks,
    Andreas
    Andreas

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Tooltip on QTableWidget header

    Did you try returning data for Qt::ToolTipRole from within your model in the headerData() method?

  3. #3
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: Tooltip on QTableWidget header

    And with QTableWidget you could use header items:
    Qt Code:
    1. QTableWidgetItem* headerItem = tableWidget->horizontalHeaderItem(0);
    2. if (headerItem)
    3. headerItem->setToolTip("Hello, world!");
    To copy to clipboard, switch view to plain text mode 
    J-P Nurmi

  4. The following user says thank you to jpn for this useful post:

    ghorwin (29th October 2007)

  5. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Tooltip on QTableWidget header

    All these of course provided that either the header view or the basic view can handle it. QHeaderView is a very limited class when it comes to model/view features.

  6. #5
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: Tooltip on QTableWidget header

    Quote Originally Posted by wysota View Post
    All these of course provided that either the header view or the basic view can handle it. QHeaderView is a very limited class when it comes to model/view features.
    Yup, QHeaderView can handle tooltips out of the box.
    J-P Nurmi

Similar Threads

  1. QTableWidget NW corner header item?
    By McKee in forum Qt Programming
    Replies: 9
    Last Post: 30th May 2012, 23:44
  2. Replies: 2
    Last Post: 14th August 2007, 15:16
  3. Replies: 0
    Last Post: 10th November 2006, 13:46
  4. QTableWidget, header behavior
    By hyling in forum Qt Programming
    Replies: 1
    Last Post: 14th October 2006, 08:03
  5. How to delete header on QTableWidget
    By jlbrd in forum Qt Programming
    Replies: 2
    Last Post: 18th July 2006, 21:00

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.