PDA

View Full Version : Testing qtabwidget tab change.



shud
13th November 2009, 11:22
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,

high_flyer
13th November 2009, 11:47
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.

shud
13th November 2009, 13:20
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.

high_flyer
13th November 2009, 15:46
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.

shud
13th November 2009, 16:00
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 .

high_flyer
16th November 2009, 09:18
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.

shud
16th November 2009, 18:15
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.

high_flyer
17th November 2009, 10:30
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().