Results 1 to 4 of 4

Thread: QHeaderView Sort Indicator sizing

  1. #1
    Join Date
    Dec 2007
    Location
    Austin, TX
    Posts
    43
    Thanks
    12
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Question QHeaderView Sort Indicator sizing

    I have a project with multiple QTableViews with sortable columns. Unfortunately, my users dislike the size of the arrow for the Sort Indicator in the QHeaderView. I've seen that I can change the image in a style sheet, but is there an easy way to just resize what's currently there? I ask, because the image would have to be skin color sensitive (I don't want black on black or something like that -- unless I could make sure it's sunken like the current arrow).

    Has anyone done/tried something like this? (I couldn't find anything on the forums, and usually I'm pretty good with searches.)

    Thanks,
    Vycke

  2. #2
    Join Date
    Oct 2006
    Location
    New Delhi, India
    Posts
    2,467
    Thanks
    8
    Thanked 334 Times in 317 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QHeaderView Sort Indicator sizing

    How about reimplementing / subclassing the headerview ??
    or may be style sheets might also be a good option as u said.

  3. #3
    Join Date
    Dec 2007
    Location
    Austin, TX
    Posts
    43
    Thanks
    12
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QHeaderView Sort Indicator sizing

    Well, I tried the Style Sheet... which worked, except you can't use the Palette with Style Sheets (and since I have user-selectable palettes, able to be changed on the fly, this isn't good).

    The QHeaderView is subclassed already in the app, but I have been unable to get paintSection() to override properly -- it appears that all the sections wind up selected/sunken, or it doesn't update the old selected section when you select a new one. I'm probably doing it wrong somehow, so I'll go over some other code I have (that rotates headers 90 degrees) and try this again.

    If anyone else has a suggestion, I'm open to it

    Vycke

  4. #4
    Join Date
    Dec 2007
    Location
    Austin, TX
    Posts
    43
    Thanks
    12
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Lightbulb Re: QHeaderView Sort Indicator sizing

    Ok, just so anyone else trying to do the same thing has an answer, here's what I did:

    Qt Code:
    1. //In the constructor for the Header subclass
    2. m_styleSet = "QHeaderView::down-arrow { image: url(:/images/down_arrow.png); width: 13px; height:9px; subcontrol-position: bottom right;} "
    3. "QHeaderView::up-arrow { image: url(:/images/up_arrow.png); subcontrol-position: bottom right; } "
    4. "QHeaderView:: section { color: %1; background-color: %2; }";
    5.  
    6. QString setStyle = m_styleSet.arg(QApplication::palette().windowText().color().name()).arg(QApplication::palette().window().color.name());
    7. this->setStyleSheet(setStyle);
    To copy to clipboard, switch view to plain text mode 

    I installed an event filter:

    Qt Code:
    1. bool CHeaderView::eventFilter(QObject* obj, QEvent* event)
    2. {
    3. if ((event->type() == QEvent::ApplicationPaletteChange) ||
    4. (event->type() == QEvent::PaletteChange))
    5. {
    6. QString setStyle = m_styleSet.arg(QApplication::palette().windowText().color().name()).arg(QApplication::palette().window().color.name());
    7. this->setStyleSheet(setStyle);
    8. return true;
    9. }
    10. return QHeaderView::eventFilter(obj,event);
    11. }
    To copy to clipboard, switch view to plain text mode 

    This allows for palette changes & still gives me the arrow that I want (the .pngs)

    Vycke

Similar Threads

  1. QTreeWidget (Row Check, Custom Sort)
    By AaronMK in forum Qt Programming
    Replies: 3
    Last Post: 8th January 2008, 16:55
  2. How to sort the treeWidget item according to size and date
    By santosh.kumar in forum Qt Programming
    Replies: 3
    Last Post: 23rd October 2007, 11:32
  3. QHeaderView as a banner
    By mclark in forum Qt Programming
    Replies: 1
    Last Post: 21st March 2007, 20:28
  4. How to sort a QComboBox in Qt4
    By guenthk in forum Qt Programming
    Replies: 7
    Last Post: 25th September 2006, 19:35
  5. Renumbering Row Headers of QHeaderView
    By mclark in forum Newbie
    Replies: 4
    Last Post: 11th September 2006, 16:04

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.