本文整理汇总了C++中TabWidget::ensureTabVisible方法的典型用法代码示例。如果您正苦于以下问题:C++ TabWidget::ensureTabVisible方法的具体用法?C++ TabWidget::ensureTabVisible怎么用?C++ TabWidget::ensureTabVisible使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TabWidget
的用法示例。
在下文中一共展示了TabWidget::ensureTabVisible方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Label
//.........这里部分代码省略.........
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));
auto ib = panel->add<IntBox<int>>();
ib->setEditable(true);
b = panel->add<Button>("", ENTYPO_ICON_FORWARD);
b->setFixedSize(Vector2i(22, 22));
ib->setFixedHeight(22);
b->setCallback([tabWidget, ib] {
int value = ib->value();
if (value >= 0 && value < tabWidget->tabCount()) {
tabWidget->setActiveTab(value);
tabWidget->ensureTabVisible(value);
}
});
window = new Window(this, "Grid of small widgets");
window->setPosition(Vector2i(425, 300));
GridLayout *layout =
new GridLayout(Orientation::Horizontal, 2,
Alignment::Middle, 15, 5);
layout->setColAlignment(
{ Alignment::Maximum, Alignment::Fill });