0

In my program I am using QtTabWidget in which the user can dynamically add tabs as per their needs. I think that the norm of an "Add Tab (+)" Button is now defined by the way we see it in our web browsers like chrome. Which is why I would like to replicate such a button in my program. Please find an example image of what I want my button to look like.

Example of the requirement

I have found a few people asking this question but not a solid solution to it yet. An example solution is "https://stackoverflow.com/questions/22616446/add-plus-button-to-tabwidget-pyqt4" however the main problem with this is that the new tab button is a corner widget which appears at the top right hand corner of my screen (see image below). Although I would prefer it to be dynamically positioned on the tab bar where it is just adjacent to the final tab that is open.

Corner tab button

  • Having a very similar-looking button right next to the tab seems like a rather questionable design. As a user, I could see myself constantly clicking that by mistake. A corner button seems a much better solution. Either that, or double-clicking anywhere on the tab-bar to open a new tab (as in firefox, for example). – ekhumoro May 19 '22 at 10:23
  • @SarimCharania See [this related answer](https://stackoverflow.com/a/71624309) and look for the code related to tab changes and `addButton` geometry. – musicamante May 19 '22 at 10:31
  • Thanks @musicamante this seems like a very relevant example, I can understand how the code uses the current position of the button to readjust it in case of any changes to the tab bar. But I can not understand how to set the add button's initial position. Maybe I am missing something, can you help me find that part in the code ? TIA – Sarim Charania May 19 '22 at 11:54
  • @SarimCharania the initial position is on the top left just like any widget created with a parent, so you shouldn't need to set anything at all. – musicamante May 19 '22 at 12:01
  • I am trying to use the QRect of the last tab to set the geometry of my button I think that would be the best solution for me (feel free to suggest improvements ) but for some reason when I set the Geometry of the button the button stops responding to clicks. It doesnt produce any error or anything its just that the button cant be clicked anymore. Do you have any suggestions as to why this might be happening? – Sarim Charania May 19 '22 at 14:16

0 Answers0