Results 1 to 5 of 5

Thread: QTabWidget problem

  1. #1
    Join Date
    Nov 2010
    Posts
    5
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default QTabWidget problem

    Hi all,

    I have a tab with 3 pages. When I switch tab page, I have the QTabWidget::currentChanged(int) signal, however, this signal is emitted after the page is switched....

    Is there any way to capture this signal before it switches tab?

    Thank you

  2. #2
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: QTabWidget problem

    This sounds like you are on a wrong design path.
    If you explain what it is you want to achieve and why, we might help you to solve it correctly.
    ==========================signature=============== ==================
    S.O.L.I.D principles (use them!):
    https://en.wikipedia.org/wiki/SOLID_...iented_design)

    Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.

  3. #3
    Join Date
    Nov 2010
    Posts
    5
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: QTabWidget problem

    Quote Originally Posted by high_flyer View Post
    This sounds like you are on a wrong design path.
    If you explain what it is you want to achieve and why, we might help you to solve it correctly.
    Yes, thank you. I will try to explain it a bit more clearly.

    I have 3 tab pages. When I switch from one to the other. I need to check if widgets on one page have been modified, if they are, when I switch tab, I will ask the user if they want to discard or save them. If I use the QTabWidget::currentChanged(int), I will go to the other tab directly, without me being able to properly get user response...(discard or save)...

    At the moment I'm trying to subclass QTabWidget such that I can get the internal QTabBar (since it's protected). But then again, QTabBar also only has currentChanged(int) signal...I'm having difficulties subclassing QTabBar and install custom signals.................Thanks

  4. #4
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: QTabWidget problem

    If I use the QTabWidget::currentChanged(int), I will go to the other tab directly, without me being able to properly get user response...(discard or save)...
    Why not?
    the user will not see the difference if the message box comes on just as the new tab got shown or when the old tab is still there (or, the difference has no effect on the user).
    The user has to interact with the message box any how, not with the tab.
    ==========================signature=============== ==================
    S.O.L.I.D principles (use them!):
    https://en.wikipedia.org/wiki/SOLID_...iented_design)

    Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.

  5. #5
    Join Date
    Nov 2010
    Posts
    5
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: QTabWidget problem

    Quote Originally Posted by high_flyer View Post
    Why not?
    the user will not see the difference if the message box comes on just as the new tab got shown or when the old tab is still there (or, the difference has no effect on the user).
    The user has to interact with the message box any how, not with the tab.
    Yes many thanks on your input.

    I could also cache a variable recording current tab...and this issue can be fixed..

    However, I am trying a way that does not cache states, and my UI was designed in Qt Creator...(I could also bypass this problem by hard-coding UI components).....
    Thanks all the ways

Similar Threads

  1. QTabWidget problem
    By alan lenton in forum Qt Programming
    Replies: 5
    Last Post: 25th July 2016, 16:16
  2. QTabWidget problem
    By Strongoloid in forum Newbie
    Replies: 2
    Last Post: 10th September 2009, 20:38
  3. StyleSheet Problem with QTabWidget
    By December in forum Qt Programming
    Replies: 1
    Last Post: 8th August 2007, 22:16
  4. grabeWidget & QTabWidget problem
    By conglu in forum Qt Programming
    Replies: 7
    Last Post: 24th April 2007, 14:42
  5. QTabWidget Parenting Problem
    By mclark in forum Newbie
    Replies: 4
    Last Post: 18th January 2007, 15:20

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.