Results 1 to 8 of 8

Thread: Testing qtabwidget tab change.

  1. #1
    Join Date
    Jul 2009
    Posts
    15
    Thanks
    1

    Default Testing qtabwidget tab change.

    Hi,
    I´m trying to test a tab change event of qtabwidget but I don´t know the dimensions of the tabs , because the QtabBar is a protected member of qtabwidget. How can I know the point of each tab ?
    I need that point to call this method :
    QTest::mouseClick ( QWidget * widget, Qt::MouseButton button, Qt::KeyboardModifiers modifier = 0, QPoint pos = QPoint(), int delay = -1 )

    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: Testing qtabwidget tab change.

    what for do you need to know where did you click on the tab bar?
    I ask, since it can most probably be dealt with in a different (probably better) way.
    ==========================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
    Jul 2009
    Posts
    15
    Thanks
    1

    Default Re: Testing qtabwidget tab change.

    Quote Originally Posted by high_flyer View Post
    what for do you need to know where did you click on the tab bar?
    I ask, since it can most probably be dealt with in a different (probably better) way.
    I made a widget who can add qtabwidgets, but they are shown at the same time . In order to change the state of each widget I need to know if the user clicks in a tabbar . I want to test that , but it´s so difficult know where is the point of the tabbar.

  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: Testing qtabwidget tab change.

    I made a widget who can add qtabwidgets, but they are shown at the same time .
    You mean both tabs are shown at the same time? or something else?
    Can you post a screenshot?

    I made a widget who can add qtabwidgets, but they are shown at the same time . In order to change the state of each widget I need to know if the user clicks in a tabbar .
    I am sorry if I don't follow, but QTabWidget does everything for you.
    All you have to do is add pages to it, and when you click the tab bar the correct page will be shown.
    But I probably still don't understand the what it is you are trying to explain.
    From what you wrote it looks like you are trying to make a QTabWidget, but as I said, Qt has one.
    ==========================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
    Jul 2009
    Posts
    15
    Thanks
    1

    Default Re: Testing qtabwidget tab change.

    Ok . Let´s go. An example:
    I have a widget that insight it has 2 tabwidgets. The tabwidgets are shown at the same time , but only one is active . Ok . In order to actvate the other tabwidget the user must click in the tab of the inactive tabwidget (I want to test this user click ).
    Do you understand me ?
    It´s simply a widget who has two ore more tabwidgets but only one is active , and if the user want to activate other it must click a tab .

  6. #6
    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: Testing qtabwidget tab change.

    Yes, now the problem is clear, what is not clear however is the sense in such a setup.

    The tabwidgets are shown at the same time , but only one is active .
    So you mean by not active - disabled? does isEnabled() return false for the not active widget?


    What is the sense to have a widget be disabled, if you want it to behave just like an enabled widget?
    A disabled widget per definition should not respond to mouse and keyboard input.
    If all you want is to make it apear as disabled, but not behave as one, you better change the way it is being drawn with or with out focus for example.
    The reason is, that a widget set with senEnabled(false) does not receive keyboard and mouse events.
    ==========================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.

  7. The following user says thank you to high_flyer for this useful post:

    shud (16th November 2009)

  8. #7
    Join Date
    Jul 2009
    Posts
    15
    Thanks
    1

    Default Re: Testing qtabwidget tab change.

    It`s difficult to explain the situation, but one widget must be active and the other disable because it must not receive the mouse events. But in order to change the state I need that the disable widget receive a mouse event to activate it.

  9. #8
    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: Testing qtabwidget tab change.

    but one widget must be active and the other disable because it must not receive the mouse events. But in order to change the state I need that the disable widget receive a mouse event to activate it.
    You are mixing things.
    If you need to react to some keyboard/mouse events, then you can't have your widget disabled - So don't disable it.

    What you want is a SELECTIVE reaction to events.
    For that you can install an event filter for that widget:
    see QObject::installEventFilter().
    ==========================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.

Similar Threads

  1. How to change color of Tab in QTabWidget?
    By rajesh in forum Qt Programming
    Replies: 10
    Last Post: 21st October 2013, 07:52
  2. Segment fault using a Qt plugin with QTabWidget
    By tarod in forum Qt Programming
    Replies: 2
    Last Post: 14th July 2009, 10:27
  3. How to change the style of QTabWidget
    By iamjayanth in forum Qt Programming
    Replies: 1
    Last Post: 24th April 2009, 12:07
  4. Changing the background of QTabWidget
    By ike in forum Qt Tools
    Replies: 2
    Last Post: 7th November 2008, 13:43
  5. How do I add new tab to QTabWidget
    By pcmantinker in forum Qt Programming
    Replies: 2
    Last Post: 6th June 2008, 04:24

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.