本文整理汇总了C++中TabWidget::tabCount方法的典型用法代码示例。如果您正苦于以下问题:C++ TabWidget::tabCount方法的具体用法?C++ TabWidget::tabCount怎么用?C++ TabWidget::tabCount使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TabWidget
的用法示例。
在下文中一共展示了TabWidget::tabCount方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Label
//.........这里部分代码省略.........
window->setPosition(Vector2i(425,15));
window->setLayout(new GroupLayout());
TabWidget* tabWidget = window->add<TabWidget>();
Widget* layer = tabWidget->createTab("Color Wheel");
layer->setLayout(new GroupLayout());
// Use overloaded variadic add to fill the tab widget with Different tabs.
layer->add<Label>("Color wheel widget", "sans-bold");
layer->add<ColorWheel>();
layer = tabWidget->createTab("Function Graph");
layer->setLayout(new GroupLayout());
layer->add<Label>("Function graph widget", "sans-bold");
Graph *graph = layer->add<Graph>("Some Function");
graph->setHeader("E = 2.35e-3");
graph->setFooter("Iteration 89");
VectorXf &func = graph->values();
func.resize(100);
for (int i = 0; i < 100; ++i)
func[i] = 0.5f * (0.5f * std::sin(i / 10.f) +
0.5f * std::cos(i / 23.f) + 1);
// Dummy tab used to represent the last tab button.
tabWidget->createTab("+");
// A simple counter.
int counter = 1;
tabWidget->setCallback([tabWidget, this, counter] (int index) mutable {
if (index == (tabWidget->tabCount()-1)) {
// When the "+" tab has been clicked, simply add a new tab.
string tabName = "Dynamic " + to_string(counter);
Widget* layerDyn = tabWidget->createTab(index, tabName);
layerDyn->setLayout(new GroupLayout());
layerDyn->add<Label>("Function graph widget", "sans-bold");
Graph *graphDyn = layerDyn->add<Graph>("Dynamic function");
graphDyn->setHeader("E = 2.35e-3");
graphDyn->setFooter("Iteration " + to_string(index*counter));
VectorXf &funcDyn = graphDyn->values();
funcDyn.resize(100);
for (int i = 0; i < 100; ++i)
funcDyn[i] = 0.5f *
std::abs((0.5f * std::sin(i / 10.f + counter) +
0.5f * std::cos(i / 23.f + 1 + counter)));
++counter;
// We must invoke perform layout from the screen instance to keep everything in order.
// This is essential when creating tabs dynamically.
performLayout();
// Ensure that the newly added header is visible on screen
tabWidget->ensureTabVisible(index);
}
});
tabWidget->setActiveTab(0);
// A button to go back to the first tab and scroll the window.
panel = window->add<Widget>();
panel->add<Label>("Jump to tab: ");
panel->setLayout(new BoxLayout(Orientation::Horizontal,
Alignment::Middle, 0, 6));