I would like to simulate a button click to switch from one tab to another after a specific action has been performed. I.e. say there are two tabs, and I am currently located in the second tab. I click a button in the second tab which calls a function that changes the second tab to the first tab. I am not sure how to "mimic" the button click that Tcl/TK handles when switching tabs using the mouse. Is there a way to do this? Thank you!
Tab notebooks have a select method that does tab selection. Which tab to switch to can be chosen by a few schemes, but the important ones for most code are:
By index (counting from zero; 0 for the first tab, 1 for the second, ...)
By handle of managed child widget (often a frame, but not necessarily)
Related
I need to switch from current tab to another without clicking on the tab itself.
In Clarity's documentation, you can see that the *clrIfActive directive accepts a boolean input to force a tab to activate.
So in your case, just pass true to the *clrIfActive of the tab you want to programmatically select. How you do that depends on how you create your tab in the first place: statically, with an *ngFor, based on a specific tab model, ... We can't help you out more unless you provide an example of what you are trying to do.
I have a tab pane that contains a bunch of tabs (obviously). Normally you can set a listener to each tab by calling setOnSelectionChanged() on the Tab. However, if the TabPane is being reorganized in some way, the tab pane automatically selects the first tab in the list. This is causing some performance issues for me so I would like to know if there is a way to know if a Mouse Click caused the Tab to be selected. Apparently tabs cannot have onMouseClick() listeners.
Whilst the solution to the answer wasn't found since tabs aren't actually nodes and don't have mouse click listeners, the performance issues were solved.
When changing tabs, I was (lazily) recreating the entire view and applying the model to the view. This caused a delay of approximately 140ms or more every time the tab changed. It was a bigger issue when implementing a search box to find the correct tab because as the tabs were being recreated from the search, the views were being recreating as the selection of the tabs changed (Tab pane automatically selects the first tab when adding new tabs).
Ultimately the design was changed to having the controller create the view once, and simply hooking the model to the view as the tab changed instead of recreating the view over and over.
I highly recommend looking at this post if your having performance issues and are relatively new to MVC/JavaFX programming:
Scene loads too slow
Currently changing tabs take approximately 15ms which is a significant improvement!
I am writing an application with PyQt and QT4. I am using a QTabWidget and have set my Tabs to closable and have connected the tabCloseRequsted signal to a method.
self.ui.tabWidget.tabCloseRequested.connect(self.onTabClose)
def onTabClose(self,index):
self.ui.tabWidget.removeTab(index)
This works fine as long as I only close the last Tab Page but if have say 5 Tabs open and close the second Tab the 3rd, 4th and 5th Tab also close. I suppose the way to work around this is to move the tab I want to close to the end so it has the highest index.
One other thing however. Users can create tabs, so when one is closed I don't know if there are one, two or ten tabs open.
How do I move a tab page? or even better is there a better way to close a Tab page?
OK, I found the problem my self. I had put the self.ui.tabWidget.tabCloseRequested.connect(self.onTabClose) in the same method as that which creates new tabs. This meant that if 5 tabs were created, then when one was closed the tabCloseReqested fired 5 times. By putting this connect statement in the init of my class like I should have done it is only defined once and only fires once when a tab is closed.
I'm trying to design a UI in Qt and I can't find anywhere in the designer a button which can be "droped down" like combobox. What I mean by that is that I would like to have this button with his "default" option choosen so if I like it I would have to just click on it but if I would like to choose different option I would be able to clik the little arrow on the right side of this button and then pick option suitable for me at that moment.
You're looking for a QToolButton that has a set of actions or a menu set on it. From the documentation, the QToolButton::ToolButtonPopupMode...
Describes how a menu should be popped up for tool buttons that has a menu set or contains a list of actions.
Of it's values, the two that I see most frequently are DelayedPopup:
After pressing and holding the tool button down for a certain amount of time (the timeout is style dependant, see QStyle::SH_ToolButton_PopupDelay), the menu is displayed. A typical application example is the "back" button in some web browsers's tool bars. If the user clicks it, the browser simply browses back to the previous page. If the user presses and holds the button down for a while, the tool button shows a menu containing the current history list
And MenuButtonPopup:
In this mode the tool button displays a special arrow to indicate that a menu is present. The menu is displayed when the arrow part of the button is pressed.
I have a list control and i want the user to be able to select many items at a time. Thus I want it to act that if the control key is pressed while he is clicking. Eg if he clicks on a selected row it should become unselected and if he clicks on a unselected row it should become selected.
Do you have any idea how to do this?
Thanks,
Dennis
If you want to follow standard UI Precedent; then set allowMultipleSelection to true and teach your users to use the control and/or shift button to select multiple items.
If you want to select multiple items without having the using press the shift or control button you'll have to extend the List class. I did a sample a while ago using the DataGrid:
http://www.flextras.com/blog/index.cfm/2009/7/23/Flextras-Friday-Lunch--Episode-22--07032009--Auto-Select-DataGrid
http://www.flextras.com/labs/AutoSelectDataGrid/
http://www.flextras.com/labs/AutoSelectDataGrid/srcview/index.html
You can probably use the same technique with a List. But, I don't recommend this approach.