[Qt-creator] QTabWidget in QDialog

Kevin Krammer kevin.krammer at kdab.com
Mon Dec 30 12:56:14 CET 2013


On Monday, 2013-12-30, 01:24:51, Tom Isaacson wrote:
> I've created a basic dialog in Qt Creator that has a tab widget to organise
> the controls. This works fine, but I don't understand how to make it so the
> controls on a particular tab belong to that tab rather than the dialog. In
> Object Inspector the controls appear under the tab but when I access them
> in code via "ui->" they're part of the dialog. This means every time I add
> a tab the amount of code and controls in my dialog has to be extended.

The widgets are children of the respective tab page or of a container on that 
page.
What you are seeing with ui-> is that each designer form is processed by a 
code generator (UIC) and it generates all the constructor and value setter 
calls into one setupUi() function (inside a file called ui_formname.h)

If you want to have each tab page separated on the code level, simply design 
each page as its own form (template type Widget), implement their 
functionality in their respective header and source files and add them to the 
tab widget either by widget promotion in designer or by creating their 
instances in the dialog's constructor and adding them to the tab widget there.

Cheers,
Kevin
-- 
Kevin Krammer | kevin.krammer at kdab.com | Software Engineer
Klarälvdalens Datakonsult AB, a KDAB Group company
Tel. Sweden (HQ) +46-563-540090, USA +1-866-777-KDAB(5322)
KDAB - Qt Experts - Platform-independent software solutions
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 5918 bytes
Desc: not available
URL: <http://lists.qt-project.org/pipermail/qt-creator/attachments/20131230/4b8c7426/attachment.bin>


More information about the Qt-creator mailing list