本文整理汇总了C++中QStackedWidget::layout方法的典型用法代码示例。如果您正苦于以下问题:C++ QStackedWidget::layout方法的具体用法?C++ QStackedWidget::layout怎么用?C++ QStackedWidget::layout使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QStackedWidget
的用法示例。
在下文中一共展示了QStackedWidget::layout方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: resizeAndUpdateLayout
void YaToolBoxPage::resizeAndUpdateLayout(QSize size)
{
resize(size);
layout()->invalidate();
layout()->activate();
// work-around scrollbars showing at an incorrect place
invokeResized(widget_);
QStackedWidget* stack = dynamic_cast<QStackedWidget*>(widget_);
if (stack && stack->currentWidget()) {
stack->layout()->invalidate();
stack->layout()->activate();
invokeResized(stack->currentWidget());
}
button_->updateMask();
}
示例2: main
int main(int argc, char **argv)
{
Vals vals;
/* the application */
QApplication app(argc, argv);
app.setApplicationName(APP_NAME);
app.setWindowIcon(QIcon(":/icon"));
Window window;
/* translations */
QTranslator qtr;
if (qtr.load("qt_" + QLocale::system().name(), QTR_PATH))
app.installTranslator(&qtr);
QTranslator htr;
if (htr.load("H4KvT_" + QLocale::system().name(), ":/"))
app.installTranslator(&htr);
/* display information */
QTextEdit *text = new QTextEdit;
text->setReadOnly(true);
text->setLineWrapMode(QTextEdit::NoWrap);
text->setToolTip(Window::tr("Drop any file for hashing"));
QObject::connect(&window, &Window::idle, text, &QWidget::setEnabled);
/* compare hash */
QLineEdit *test = new QLineEdit;
HexVal hexval;
test->setValidator(&hexval);
test->installEventFilter(&window);
test->setToolTip(Window::tr("Compare hashes"));
QObject::connect(test, &QLineEdit::textChanged,
[&](const QString &newValue) { if (vals.name != "") {
std::string hashVal = newValue.toStdString();
std::transform(hashVal.begin(), hashVal.end(), hashVal.begin(), ::tolower);
std::stringstream html;
if (hashVal != "")
html << "<style>.h" << hashVal << "{color:green}</style>";
html << "<div style='margin-bottom:2; font-size:27px'><i><b>" << vals.name << "</b></i></div>";
html << "<div style='margin-bottom:7; margin-left:23; font-size:13px'>" << vals.path << "</div>";
if (!ALL(vals,"")) {
html << "<div style='font-size:13px'><table>";
if (vals.md5 != "")
html << "<tr><td>md5: </td><td class='h" << vals.md5 << "'>" << vals.md5 << "</td</tr>";
if (vals.sha1 != "")
html << "<tr><td>sha1: </td><td class='h" << vals.sha1 << "'>" << vals.sha1 << "</td</tr>";
if (vals.sha224 != "")
html << "<tr><td>sha224: </td><td class='h" << vals.sha224 << "'>" << vals.sha224 << "</td</tr>";
if (vals.sha256 != "")
html << "<tr><td>sha256: </td><td class='h" << vals.sha256 << "'>" << vals.sha256 << "</td</tr>";
if (vals.sha384 != "")
html << "<tr><td>sha384: </td><td class='h" << vals.sha384 << "'>" << vals.sha384 << "</td</tr>";
if (vals.sha512 != "")
html << "<tr><td>sha512: </td><td class='h" << vals.sha512 << "'>" << vals.sha512 << "</td</tr>";
html << "</table></div>";
}
int horizontal = text->horizontalScrollBar()->value();
int vertical = text->verticalScrollBar()->value();
text->setHtml(QString::fromStdString(html.str()));
text->horizontalScrollBar()->setValue(horizontal);
text->verticalScrollBar()->setValue(vertical);
test->setStyleSheet(ANY(vals,hashVal) ? "color:green" : "");
}});
/* error messages */
QLabel *error = new QLabel;
error->setStyleSheet("color:red");
/* test or error */
QStackedWidget *stack = new QStackedWidget;
delete stack->layout();
stack->setLayout(new Stack);
stack->addWidget(error);
stack->addWidget(test);
stack->setCurrentIndex(1);
/* toggle test or error */
QPushButton *hash = new QPushButton(QIcon(":/icon"), "");
hash->setCheckable(true);
hash->setChecked(true);
hash->setToolTip(Window::tr("Compare hashes"));
QObject::connect(hash, &QPushButton::toggled, stack, &QStackedWidget::setCurrentIndex);
/* store method */
QSettings settings("H4KvT", "H4KvT");
/* more methods */
bool more;
try {
settings.setValue("MoreHashingMethods", more = moreOrLess());
} catch (...) {
more = settings.value("MoreHashingMethods", false).toBool();
}
/* hashing method */
QComboBox *meth = new QComboBox;
meth->addItem("md5");
meth->addItem("sha1");
//.........这里部分代码省略.........