本文整理汇总了C++中QSplitter::handle方法的典型用法代码示例。如果您正苦于以下问题:C++ QSplitter::handle方法的具体用法?C++ QSplitter::handle怎么用?C++ QSplitter::handle使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QSplitter
的用法示例。
在下文中一共展示了QSplitter::handle方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: setVisibility
void PropertiesWidget::setVisibility(bool visible)
{
if (!visible && (state == VISIBLE)) {
QSplitter *hSplitter = static_cast<QSplitter *>(parentWidget());
m_ui->stackedProperties->setVisible(false);
slideSizes = hSplitter->sizes();
hSplitter->handle(1)->setVisible(false);
hSplitter->handle(1)->setDisabled(true);
QList<int> sizes = QList<int>() << hSplitter->geometry().height() - 30 << 30;
hSplitter->setSizes(sizes);
state = REDUCED;
return;
}
if (visible && (state == REDUCED)) {
m_ui->stackedProperties->setVisible(true);
QSplitter *hSplitter = static_cast<QSplitter *>(parentWidget());
hSplitter->handle(1)->setDisabled(false);
hSplitter->handle(1)->setVisible(true);
hSplitter->setSizes(slideSizes);
state = VISIBLE;
// Force refresh
loadDynamicData();
}
}
示例2: resizeToMaximum
void GTUtilsOptionsPanel::resizeToMaximum(GUITestOpStatus &os) {
QSplitter *optionsPanelSplitter = GTWidget::findExactWidget<QSplitter *>(os, "OPTIONS_PANEL_SPLITTER");
GT_CHECK(nullptr != optionsPanelSplitter, "Options panel splitter is nullptr");
QSplitterHandle *handle = optionsPanelSplitter->handle(1);
GT_CHECK(nullptr != handle, "Options panel splitter handle is nullptr");
const QPoint handleCenter = optionsPanelSplitter->mapToGlobal(handle->geometry().center());
const int delta = 500;
GTMouseDriver::dragAndDrop(handleCenter, handleCenter - QPoint(delta, 0));
}
示例3: updateParts
void QtnPropertyWidget::updateParts()
{
// clear layout
while (!m_layout->isEmpty())
m_layout->takeAt(0);
// check toolbar
// check description panel
if (m_parts & QtnPropertyWidgetPartsDescriptionPanel)
{
if (!m_descriptionSplitter)
{
// create splitter
Q_ASSERT(!m_descriptionPanel);
QSplitter* splitter = new QSplitter(Qt::Vertical, this);
// add property view
splitter->addWidget(m_propertyView);
// create description panel
m_descriptionPanel = new QLabel(splitter);
m_descriptionPanel->setTextFormat(Qt::RichText);
m_descriptionPanel->setAlignment(Qt::AlignTop);
m_descriptionPanel->setWordWrap(true);
m_descriptionPanel->setFrameStyle(QFrame::Box | QFrame::Sunken);
m_descriptionPanel->setMinimumSize(0, 0);
QSizePolicy p = m_descriptionPanel->sizePolicy();
p.setVerticalPolicy(QSizePolicy::Ignored);
p.setHorizontalPolicy(QSizePolicy::Ignored);
m_descriptionPanel->setSizePolicy(p);
// setup DblClick handler
splitter->handle(1)->installEventFilter(new QtnSplitterEventsHandler(splitter));
m_descriptionSplitter = splitter;
}
m_layout->addWidget(m_descriptionSplitter);
}
else
{
if (m_descriptionSplitter)
{
delete m_descriptionSplitter;
m_descriptionSplitter = nullptr;
m_descriptionPanel = nullptr;
}
m_layout->addWidget(m_propertyView);
}
}
示例4: setupLayout
//-----------------------------------------------------------------------------
// Function: AddressSpaceEditor::setupLayout()
//-----------------------------------------------------------------------------
void AddressSpaceEditor::setupLayout()
{
QScrollArea* scrollArea = new QScrollArea(this);
scrollArea->setWidgetResizable(true);
scrollArea->setFrameShape(QFrame::NoFrame);
QVBoxLayout* scrollLayout = new QVBoxLayout(this);
scrollLayout->addWidget(scrollArea);
scrollLayout->setContentsMargins(0, 0, 0, 0);
QWidget* topWidget = new QWidget(scrollArea);
topWidget->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
QVBoxLayout* topLayout = new QVBoxLayout(topWidget);
QHBoxLayout* nameAndGeneralLayout = new QHBoxLayout();
nameAndGeneralLayout->addWidget(&nameEditor_, 0, Qt::AlignTop);
nameAndGeneralLayout->addWidget(&generalEditor_);
topLayout->addLayout(nameAndGeneralLayout);
topLayout->addWidget(&segmentsEditor_, 1);
topLayout->setContentsMargins(0, 0, 0, 0);
QWidget* bottomWidget = new QWidget(scrollArea);
bottomWidget->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
QVBoxLayout* bottomLayout = new QVBoxLayout(bottomWidget);
bottomLayout->addWidget(&localMemMapEditor_);
bottomLayout->setContentsMargins(0, 0, 0, 0);
QSplitter* verticalSplitter = new QSplitter(Qt::Vertical, scrollArea);
verticalSplitter->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
verticalSplitter->addWidget(topWidget);
verticalSplitter->addWidget(bottomWidget);
verticalSplitter->setStretchFactor(1, 1);
QSplitterHandle* handle = verticalSplitter->handle(1);
QVBoxLayout* handleLayout = new QVBoxLayout(handle);
handleLayout->setSpacing(0);
handleLayout->setMargin(0);
QFrame* line = new QFrame(handle);
line->setLineWidth(2);
line->setMidLineWidth(2);
line->setFrameShape(QFrame::HLine);
line->setFrameShadow(QFrame::Sunken);
handleLayout->addWidget(line);
verticalSplitter->setHandleWidth(10);
scrollArea->setWidget(verticalSplitter);
}
示例5: buildWidget
void PythonEditorWidget::buildWidget() {
setWindowIcon(QIcon(":/icons/python.png"));
QWidget* content = new QWidget(this);
QVBoxLayout* verticalLayout = new QVBoxLayout(content);
////Create Buttons
QHBoxLayout* horizontalLayout = new QHBoxLayout();
QToolButton* runButton = new QToolButton(content);
QToolButton* newButton = new QToolButton(content);
QToolButton* openButton = new QToolButton(content);
QToolButton* saveButton = new QToolButton(content);
QToolButton* saveAsButton = new QToolButton(content);
QPushButton* clearOutputButton = new QPushButton(content);
runButton->setShortcut(QKeySequence(tr("F5")));
runButton->setIcon(QIcon(":/icons/python.png"));
runButton->setToolTip("Compile and run (F5)");
newButton->setIcon(QIcon(":/icons/new.png"));
newButton->setToolTip("New file (Ctrl+N)");
openButton->setIcon(QIcon(":/icons/open.png"));
openButton->setToolTip("Open Python script");
saveButton->setIcon(QIcon(":/icons/save.png"));
saveButton->setToolTip("Save (Ctrl+S)");
saveAsButton->setIcon(QIcon(":/icons/saveas.png"));
saveAsButton->setToolTip("Save as");
clearOutputButton->setText("Clear Output");
QFrame* line1 = new QFrame(content);
line1->setFrameShape(QFrame::VLine);
line1->setFrameShadow(QFrame::Sunken);
QFrame* line2 = new QFrame(content);
line2->setFrameShape(QFrame::VLine);
line2->setFrameShadow(QFrame::Sunken);
QFrame* line3 = new QFrame(content);
line3->setFrameShape(QFrame::VLine);
line3->setFrameShadow(QFrame::Sunken);
horizontalLayout->addWidget(runButton);
horizontalLayout->addWidget(line1);
horizontalLayout->addWidget(newButton);
horizontalLayout->addWidget(openButton);
horizontalLayout->addWidget(saveButton);
horizontalLayout->addWidget(saveAsButton);
horizontalLayout->addWidget(line2);
horizontalLayout->addWidget(clearOutputButton);
horizontalLayout->addWidget(line3);
QSpacerItem* horizontalSpacer =
new QSpacerItem(40, 20, QSizePolicy::Expanding, QSizePolicy::Minimum);
horizontalLayout->addItem(horizontalSpacer);
// Done creating buttons
QSplitter* splitter = new QSplitter(content);
splitter->setOrientation(Qt::Vertical);
pythonCode_ = new PythonTextEditor(content);
pythonCode_->setObjectName("pythonEditor");
pythonCode_->setUndoRedoEnabled(true);
setDefaultText();
pythonOutput_ = new QTextEdit(content);
pythonOutput_->setObjectName("pythonConsole");
pythonOutput_->setReadOnly(true);
pythonOutput_->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn);
syntaxHighligther_ =
SyntaxHighligther::createSyntaxHighligther<Python>(pythonCode_->document());
verticalLayout->addLayout(horizontalLayout);
splitter->addWidget(pythonCode_);
splitter->addWidget(pythonOutput_);
splitter->setStretchFactor(0, 1);
splitter->setStretchFactor(1, 0);
splitter->setHandleWidth(2);
// enable QSplitter:hover stylesheet
// QTBUG-13768 https://bugreports.qt.io/browse/QTBUG-13768
splitter->handle(1)->setAttribute(Qt::WA_Hover);
verticalLayout->addWidget(splitter);
setWidget(content);
connect(pythonCode_, SIGNAL(textChanged()), this, SLOT(onTextChange()));
connect(runButton, SIGNAL(clicked()), this, SLOT(run()));
connect(newButton, SIGNAL(clicked()), this, SLOT(setDefaultText()));
connect(openButton, SIGNAL(clicked()), this, SLOT(open()));
connect(saveButton, SIGNAL(clicked()), this, SLOT(save()));
connect(saveAsButton, SIGNAL(clicked()), this, SLOT(saveAs()));
connect(clearOutputButton, SIGNAL(clicked()), this, SLOT(clearOutput()));
updateStyle();
InviwoApplication::getPtr()->getSettingsByType<SystemSettings>()->pythonSyntax_.onChange(this, &PythonEditorWidget::updateStyle);
InviwoApplication::getPtr()->getSettingsByType<SystemSettings>()->pyFontSize_.onChange(this, &PythonEditorWidget::updateStyle);
}
示例6: InviwoDockWidget
//.........这里部分代码省略.........
connect(action, &QAction::triggered, [this](){open();});
}
{
auto action = toolBar->addAction(QIcon(":/icons/save.png"), tr("&Save Script"));
action->setShortcut(QKeySequence::Save);
action->setShortcutContext(Qt::WidgetWithChildrenShortcut);
action->setToolTip("Save Script");
mainWindow->addAction(action);
connect(action, &QAction::triggered, [this](){save();});
}
{
auto action = toolBar->addAction(QIcon(":/icons/saveas.png"), tr("&Save Script As..."));
action->setShortcut(QKeySequence::SaveAs);
action->setShortcutContext(Qt::WidgetWithChildrenShortcut);
action->setToolTip("Save Script As...");
mainWindow->addAction(action);
connect(action, &QAction::triggered, [this](){saveAs();});
}
{
QIcon icon;
icon.addFile(":/icons/log-append.png", QSize(), QIcon::Normal, QIcon::On);
icon.addFile(":/icons/log-clearonrun.png", QSize(), QIcon::Normal, QIcon::Off);
QString str = (appendLog_ ? "Append Log" : "Clear Log on Run");
auto action = toolBar->addAction(icon, str);
action->setShortcut(Qt::ControlModifier + Qt::Key_E);
action->setShortcutContext(Qt::WidgetWithChildrenShortcut);
action->setCheckable(true);
action->setChecked(appendLog_);
action->setToolTip(appendLog_ ? "Append Log" : "Clear Log on Run");
mainWindow->addAction(action);
connect(action, &QAction::toggled, [this, action](bool toggle) {
appendLog_ = toggle;
// update tooltip and menu entry
QString tglstr = (toggle ? "Append Log" : "Clear Log on Run");
action->setText(tglstr);
action->setToolTip(tglstr);
// update settings
settings_.beginGroup("PythonEditor");
settings_.setValue("appendLog", appendLog_);
settings_.endGroup();
});
}
{
auto action = toolBar->addAction(QIcon(":/icons/log-clear.png"), "Clear Log Output");
action->setShortcut(Qt::ControlModifier + Qt::Key_E);
action->setShortcutContext(Qt::WidgetWithChildrenShortcut);
action->setToolTip("Clear Log Output");
mainWindow->addAction(action);
connect(action, &QAction::triggered, [this](){clearOutput();});
}
// Done creating buttons
QSplitter* splitter = new QSplitter(nullptr);
splitter->setOrientation(Qt::Vertical);
pythonCode_ = new PythonTextEditor(nullptr);
pythonCode_->setObjectName("pythonEditor");
pythonCode_->setUndoRedoEnabled(true);
setDefaultText();
pythonOutput_ = new QTextEdit(nullptr);
pythonOutput_->setObjectName("pythonConsole");
pythonOutput_->setReadOnly(true);
pythonOutput_->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn);
syntaxHighligther_ =
SyntaxHighligther::createSyntaxHighligther<Python>(pythonCode_->document());
splitter->addWidget(pythonCode_);
splitter->addWidget(pythonOutput_);
splitter->setStretchFactor(0, 1);
splitter->setStretchFactor(1, 0);
splitter->setHandleWidth(2);
// enable QSplitter:hover stylesheet
// QTBUG-13768 https://bugreports.qt.io/browse/QTBUG-13768
splitter->handle(1)->setAttribute(Qt::WA_Hover);
mainWindow->setCentralWidget(splitter);
QObject::connect(pythonCode_, SIGNAL(textChanged()), this, SLOT(onTextChange()));
// close this window before the main window is closed
QObject::connect(ivwwin, &InviwoMainWindow::closingMainWindow, [this]() { delete this; });
this->updateStyle();
this->resize(500, 700);
if (app_) {
app_->getSettingsByType<SystemSettings>()->pythonSyntax_.onChange(
this, &PythonEditorWidget::updateStyle);
app_->getSettingsByType<SystemSettings>()->pyFontSize_.onChange(
this, &PythonEditorWidget::updateStyle);
app_->registerFileObserver(this);
}
unsavedChanges_ = false;
if (lastFile.size() != 0) loadFile(lastFile.toLocal8Bit().constData(), false);
setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea);
setFloating(true);
}