Leon Overweel
Leon Overweel

Reputation: 1567

Qt: Add custom new tab on button click

So I'm fairly new at Qt, and I'm looking for some guidance on creating a tabbed interface where I can add multiple tabs (with the same design but different content filling them) while the program is running. For now, I'd just like to try a simplified version where I have my widget with a "new tab" button that, every time it's clicked adds another tab containing a couple of buttons and text fields to the tab area.

I'm thinking I'll have two classes (my main class and a class for the content of the tab), with .h, .cpp and .ui files for each. Then in my main window .ui file I'd like to put the "new tab" button and the table, and in the content .ui file I'd put the stuff that goes inside the tab.

But then how do I get clicking the "new tab" button to add a copy of my content ui into a new tab?

Any help is much appreciated.

Thanks

PS: I've been looking around online for the past couple of hours, but none of the solutions I've found have worked for me (they were all highly specific answers to setups that were different from mine)

PPS: If I'm going about this all wrong, I'm willing to do it differently of course :)

Upvotes: 0

Views: 1513

Answers (1)

TWE
TWE

Reputation: 421

I think you should start with Qt examples and try to understand how to develop Qt gui applications in general. Depending on your Qt version and the technology (widgets or QML or both) there can be very different approaches.

An easy example for widgets is here: http://doc.qt.io/qt-4.8/qt-dialogs-tabdialog-example.html (comes qith qt creator)

Upvotes: 1

Related Questions