[Interest] QTabWidget activity

Murphy, Sean smurphy at walbro.com
Thu Jan 7 21:44:20 CET 2016


I'm trying to figure out the right way to show some feedback to the user and I'm stuck. Here's the setup:
- I have a QTabWidget, that has three tabs, one for live data, one for archived data, and a third tab that doesn't having much to do with this particular issue, other than it exists.
- On the first tab we plot a live feed of data from a variety of sensors
  - Also on this tab, there is a "Take Snapshot" button
  - Pressing the "Take Snapshot" button should make a copy of the current plot data under the second tab while keeping the first tab (the live data) as the current tab index 
- On the second tab, there's a child tab widget that shows the snapshots taken above, one snapshot per tab

This works fine, except that there's no real indication to the user that pressing the "Take Snapshot" button actually worked until the user clicks on the second tab and sees that the snapshot exists, so we'd like to add some sort of visual feedback that it was successful. Ideally, I'd like to blink the background color of *just* the second tab a couple times to let the user know something changed over there. But looking through QTabWidget, QTabBar, there doesn't seem to be any way of changing the background color of an specific, individual tab. I can change the text color of a specific tab using QTabBar::setTabTextColor(), but after trying that the effect is just a little too subtle. The closest thing I can find is through stylesheets using the QTabBar::tab:middle subcontrol and pseudostate, which I just luck out that it works for me because I only have 3 tabs, and I'm trying to change the middle tab. If we add more tabs later, that won't work, unless I switch it to using QTabBar::tab:last and then change the behavior that the archived data is always on the last tab.

Are there other options to change the color, or does anyone else have a better idea of how to do provide feedback to the user? The only other viable options I see is that I could either:
 - change the text on the second tab to somehow reflect something changed (like add an * or something)
 - blink an icon on the second tab using QTabBar::setTabIcon(int index, const QIcon & icon)

Sean



More information about the Interest mailing list