Qt Tutorials For Beginners 28 - QTabWidget

Qt Tutorials For Beginners 28 – QTabWidget

Views:32848|Rating:4.90|View Time:14:55Minutes|Likes:206|Dislikes:4



How do I add new tab to QTabWidget
Removes all the pages and delete them ..
QScrollArea in a QTabWidget page – Qt Centre Forum
Qt Designer QTabWidget: How to add a layout to a tab?
QTabWidget West and horizontal text – Qt Centre Forum
QTabWidget Class, Searches related to QTabWidget, qtabwidget example, qtabwidget stylesheet, qtabwidget pyqt
qtabwidget example python, qtabwidget documentation
qtabwidget background, c++ qtabwidget, qtabwidget click event

——————-Online Courses to learn—————————-
Blockchain Course –
Big Data Hadoop Course –
Java –
C++ –
AngularJS –
Python –
C-
Android –
Linux –
AWS Certified Solutions Architect –
Modern React with Redux –
MySQL –
———————-Follow———————————————
My Website –
My Blog –
My Facebook Page –
Google+ –
Twitter –
Pinterest –
Text Case Converter –
————————-Stuff I use to make videos ——————-
Stuff I use to make videos
Windows notebook –
Apple MacBook Pro –
Ubuntu notebook –
Desktop –
Microphone –
notebook mouse –
——————Facebook Links —————————————-

hello guys welcome to the next video on cutie tutorial for beginners in this video we will learn how we can use Q tab widget in QT so those of you who don't know what is a tab you can just go to tool in your QT creator IDE and then go to options and then you will be able to see these kind of tabs here general kit QT version compiler and debugger and see make so these are called Tom which you can switch interchangeably right and the main use of tabs are they if you have really too much content to show in a window you can you know segregate them using tabs so for example general tab general information kids have the information related to kids whatever you know building kits we have for example mingw or ms vc or QT versions or a compiler so these are this is the simple use of tab so if you have more information which you want to segregate then you can use tabs now what I have done is I have created a sample project and I will go to main window dot UI and first of all I will search for a cue tab here so just search for cue tab or even you can just search for tab and these will be the result and we want to drag and drop a tab widget here okay and I will add one more button here so that we will use it later so I will just add a button also here so push button okay now I will just give them a horizontal layout and then I will just provide them some layout so that it can be resizable right now there are some properties of tab which we can see so just select your tab and go to the properties and we'll show you some of the interesting properties here so here you will be able to see in queue tab widget the tab position properties so by default the position of tab is at the top which is north right now you can change the position to South and the term will go down or you can change it to west and it will go left and you can change it to East and it will go right right and by default it's not so it will be at the top so you can change this tab position also not tab shape so by default they are rounded but there are some option for example triangular so you can see the shape of tabs are now little bit triangular right so you can do this now you have the icons so you can give the icons from here so you have the icon size you can increase the icon size for example we want 32 by 32 and press ENTER and then whenever you give the icon or whenever you provide the icon to your tab then it will be bigger right now the next property is current tab text so whatever tab is selected here the text of it you can change so for example this is for example my Home tab or second tab is for example something as for something else for example C++ or third tab is something else right and you can also provide the tab name tomm name is like this object name so you have a tab widget which is the object name of the whole tab widget right but the single the tab has its own object name which is this one current term name okay now current tab icon you can provide some icon from here right now I don't have any icon but you can you know add the resources and then you can choose the icon from there right you can also provide the tooltip to your tab so whenever you run the application then it will show some tooltip for example this is home and whenever you run your application and hover over your home tab it will show you the tooltip so I will hover over here and it shows me this tooltip this is a home right so this is for that now there are some more interesting properties here for example you can check this option which says tabs closable so just click this option and you can see the close button comes on the tab right and you can write a code on what these tabs close buttons and then they will be closed right and then there is a one more option which is moveable tab so whenever you check this then you can move your tabs like this okay so there is this option also so now let's add the code for removing the tabs for example so you can just right click here and then go to slot and from here we will choose a special slot from here which is tab close request okay so just choose this slot which says tab close request and click OK it's going to create us this function and in here you can just right I will just make this a little bit bigger so we can see and then here you can just write UI and then call your tab and then you can just say remove tab okay and then you can just provide this index here as an argument and then you will be able to remove the tab so let's run the code and let's see if it removes the TAM or not so our code is compiling and it's running hopefully and when I click this button it closes right and when I click this button it closes right now for example if you want to add some tabs by clicking some button so we want to add sometimes dynamically so how we can do it so I will go to the main window and for example when I press the button I want to add in the tab so I will just change the text to add tab and then I will give a slot to its right click go to slot clicked ok and when this button is clicked I want to add a tab so I will just say UI and then tab widget and then you can just say add tab okay just call add damn it has a few you know overloads so we will use the second overload which takes first first argument as a widget and second is the text so just write new cue widget so just write new – widget and the second argument will be the text for example my third tab is Java tab and you can add something like multiple tabs so for example if I want to add multiple tabs then static text will not work but first of all let's see if the tab is added or not so I will run the code and then let's see if the tab will be added or not when we press the button so when I click add tab it adds this java terms here right but for example I want to add multiple term then at multiple Java tab the text to it which we don't want so how we can solve this problem so what we can do here is we can add a cue string so just write Q string and then we will just say tab and that this will be in the code so just provide quotes around it and give a space and then we will provide our argument to it so just write mod 0 for the first argument right and then you can just give the argument so for example argh and then you can give the argument for example the index of the tab so we will count how many tabs we have and then we will add one more tabs to it so just write count so it will give us the tab count and then we will just add plus 1 to it okay so let's run the code and let's see if it works or not for us so I will just click Add tab and add stamp 3 and when I say add tab it adds tab for top 5 times 6 something like this now you may ask an obvious question here that okay we have a new tab but where is the content how we can add some content to the tab so normally when we go to the main window dot UI from here you can add the content to your tab for example something like this some buttons or some added text or some other you know other widgets from your labels or any other widgets something like this right and in the other tab it has its own window so you can add different tabs here also something like this ok so these are the tabs which are already present so this is easy to do it we can drag and drop a widget and you know place it here and do something with it but we are also adding some tabs dynamically here so we will here and we are adding some time dynamically so how we can add this push button and everything to this so the simple idea is you can create a tab window and add it to your tab so you can right click on your project and then click add new and we will just choose QT and then just choose designer from class from here and then click Choose and this time we will add or choose this widget template from here so just choose widget template and click Next and leave it as default and click Next or if you want to change this you can change it but for now I'm not going to change it right so next and finish okay so this is going to create one more reform for us which is formed form dot UI right so we will go here and then we can you know provide some widgets here and do for some functionality I am NOT going to add some functionality here I will just add some widgets here so I will add text view and for example I want to add some labels here and I want to add a push button for example right and I will select all of them and I will give them a horizontal new layout and then I will just give a horizontal layout to all the window like this okay so for example this is my widget and I want to show this widget in the tab when I add one term for example right so I will once again go to my main window dot CPP file and I will add first of all include this header for form dot H right to use this class so I will just include this and I will just say form dot H which allows me to use this class which is form class right so I can just copy the name of the class and instead of this qwidget I can just say new form so this is the class name which we have created which is this one right and when we run our code and hopefully it will work for us so the code is running and when I click add a tab it adds the tab with this you know the widget we have created so it has this text label and pull button and this textview right and I will add one more tab and you can see it adds one more term for example when I press this add tab this tab is not selected automatically you see the SAP tab is created but I want to select it automatically also right so what I can do here is I can just go here and I will just write UI and tab widget and then I will say set current index and the current index will be UI time widget count so just use count and then minus one right and then run the code and let's see what happens when we create a tab it should be selected so you see it's automatically selected current index right so like this okay so in this way you can use cue tab widget class and QT I hope you enjoyed this video please rate comment subscribe and bye for now

18 Replies to “Qt Tutorials For Beginners 28 – QTabWidget”

  1. catphish81

    How to add an additional 'tab' before runtime: by this i mean "add it in the QT Creator UI builder that we see in this video".

    So I found that the 'tabs' as we commonly call them are called 'Pages' in the Qt software.

    If you opposite-click in the UI editor where the tabs (Pages) are shown, from the popup menu you can select "Insert Page" and then select Before or After the Current Page.
    To remove a Page, click the Page tab in the UI editor then opposite-click and select "Page X of Y" (where X and Y are integer values depending on how many Pages are in your project) and then select "Delete".

    It would be better if the video uses terminology that Qt uses because I've found tab widgets can be really confusing until you understand the "Page" concept.

  2. luka stajcic

    Hello !
    Can you explain me please what does that 2nd argument in addTab function do and what does .arg() function do. And what is that %0 symbol. Thank you

  3. Rogelio Gloria

    I was wonder how you can access the tab to tab mouse click via the abbreviated properties editor(ie…spreadsheet looking gui interface). I remember from other application you can turn on and off the double click. Another important thing is turning on or off inheritance or parent,child…function which is the basis of Objected Oriented Programming. Do you have a link of a product comparison matrix between the free app to the license app?

  4. Cafer Tayyar Usta

    How can i change the current tab index in another form? Im created tabWidget that have 3 index. I want to change that index when I click the push button from another form.

  5. Cey Kara

    I don't understand why u make: ui->tabWidget->setCurrentIndex(ui->tabWidget->count()-1); the minus one ?
    because count() gives us the actual tab number, but why do we have make -1 ?

  6. Toni

    Thank you very much for such effort doing video tutorials.
    I am learning Qt and currently watching tutorial 7. It is really helpful;)

Leave a Reply

Your email address will not be published. Required fields are marked *