本文整理汇总了C++中QScrollArea::setSizePolicy方法的典型用法代码示例。如果您正苦于以下问题:C++ QScrollArea::setSizePolicy方法的具体用法?C++ QScrollArea::setSizePolicy怎么用?C++ QScrollArea::setSizePolicy使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QScrollArea
的用法示例。
在下文中一共展示了QScrollArea::setSizePolicy方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: setup
virtual int setup() {
QScrollArea *qw;
QWidget *qChild;
uint32_t flags;
GWEN_WIDGET *wParent;
QSizePolicy::Policy hpolicy=QSizePolicy::Minimum;
QSizePolicy::Policy vpolicy=QSizePolicy::Minimum;
QLayout *qLayout;
flags=GWEN_Widget_GetFlags(_widget);
wParent=GWEN_Widget_Tree_GetParent(_widget);
qw=new QScrollArea();
qChild=new QWidget();
qChild->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
qw->setWidget(qChild);
qLayout=new QVBoxLayout(qChild);
qw->setWidgetResizable(true);
/* handle flags */
if (flags & GWEN_WIDGET_FLAGS_FILLX)
hpolicy=QSizePolicy::Expanding;
if (flags & GWEN_WIDGET_FLAGS_FILLY)
vpolicy=QSizePolicy::Expanding;
qw->setSizePolicy(hpolicy, vpolicy);
GWEN_Widget_SetImplData(_widget, QT5_DIALOG_WIDGET_REAL, (void*) qw);
GWEN_Widget_SetImplData(_widget, QT5_DIALOG_WIDGET_LAYOUT, (void*) qLayout);
if (wParent)
GWEN_Widget_AddChildGuiWidget(wParent, _widget);
return 0;
}
示例2: QDockWidget
PaletteBox::PaletteBox(QWidget* parent)
: QDockWidget(tr("Palettes"), parent)
{
setObjectName("palette-box");
setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea);
QScrollArea* sa = new QScrollArea;
sa->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Minimum);
sa->setContextMenuPolicy(Qt::CustomContextMenu);
sa->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
sa->setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded);
sa->setWidgetResizable(true);
setWidget(sa);
QWidget* paletteList = new QWidget;
sa->setWidget(paletteList);
vbox = new QVBoxLayout;
paletteList->setLayout(vbox);
_dirty = false;
vbox->setMargin(0);
vbox->setSpacing(1);
vbox->addStretch();
paletteList->show();
// connect(sa, SIGNAL(customContextMenuRequested(const QPoint&)), SLOT(contextMenu(const QPoint&)));
}
示例3: QWidget
EffectStackEdit::EffectStackEdit(QWidget *parent) :
QWidget(parent),
m_in(0),
m_out(0),
m_frameSize(QPoint())
{
setSizePolicy(QSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding));
QVBoxLayout *vbox1 = new QVBoxLayout(parent);
vbox1->setContentsMargins(0, 0, 0, 0);
vbox1->setSpacing(0);
QScrollArea *area = new QScrollArea;
QWidget *wid = new QWidget(parent);
area->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
area->setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded);
wid->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Minimum));
area->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::MinimumExpanding));
vbox1->addWidget(area);
area->setWidget(wid);
area->setWidgetResizable(true);
m_vbox = new QVBoxLayout(wid);
m_vbox->setContentsMargins(0, 0, 0, 0);
m_vbox->setSpacing(0);
wid->show();
}
示例4: QWidget
NotifyManager::NotifyManager(QWidget *parent) :
QWidget(parent),
m_dbus(new Notification("com.deepin.dde.Notification", "/com/deepin/dde/Notification", QDBusConnection::sessionBus(), this))
{
QWidget *widget = new QWidget;
m_connectLayout = new QVBoxLayout(widget);
m_connectLayout->setMargin(0);
m_connectLayout->setSpacing(1);
m_connectLayout->addStretch();
QScrollArea *scrollarea = new QScrollArea;
scrollarea->setWidget(widget);
scrollarea->setObjectName("scrollarea");
scrollarea->setWidgetResizable(true);
scrollarea->setFocusPolicy(Qt::NoFocus);
scrollarea->setFrameStyle(QFrame::NoFrame);
scrollarea->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Expanding);
scrollarea->setContentsMargins(0, 0, 0, 0);
scrollarea->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
scrollarea->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
scrollarea->setStyleSheet("background-color:transparent;");
QScrollBar *bar = scrollarea->verticalScrollBar();
connect(bar, &QScrollBar::valueChanged, this, [=](int value){
if (m_checkIndex && value == bar->maximum())
onLoadAgain();
});
QVBoxLayout *mainLayout = new QVBoxLayout;
mainLayout->setMargin(0);
mainLayout->setSpacing(0);
m_clearButton = new DImageButton;
m_clearButton->setText(tr("Clear all"));
m_clearButton->setStyleSheet("padding: 4px 0;");
mainLayout->addWidget(m_clearButton, 0, Qt::AlignHCenter);
mainLayout->addWidget(scrollarea);
setLayout(mainLayout);
m_clearButton->setVisible(false);
connect(m_clearButton, &DImageButton::clicked, this, &NotifyManager::onCloseAllItem);
connect(m_dbus, &Notification::RecordAdded, this, &NotifyManager::onNotifyAdded);
m_dbus->setSync(false);
QDBusPendingReply<QString> notify = m_dbus->GetAllRecords();
QDBusPendingCallWatcher *notifyWatcher = new QDBusPendingCallWatcher(notify, this);
connect(notifyWatcher, &QDBusPendingCallWatcher::finished, this, &NotifyManager::onNotifyGetAllFinished);
}
示例5: sizePolicy
SearchPinyin::SearchPinyin()
{
QVBoxLayout* vtLayout = new QVBoxLayout(this);
QLabel* pinyinLabel = new QLabel(this);
pinyinLabel->setText("Pinyin:");
vtLayout->addWidget(pinyinLabel);
pinyin = new QLineEdit(this);
vtLayout->addWidget(pinyin);
QLabel* disambiguateLabel = new QLabel(this);
disambiguateLabel->setText("Disambiguate:");
disambiguateLabel->setObjectName(QString::fromUtf8("label"));
vtLayout->addWidget(disambiguateLabel);
QScrollArea* candidatesScrollArea = new QScrollArea(this);
QSizePolicy sizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
sizePolicy.setHorizontalStretch(0);
sizePolicy.setVerticalStretch(0);
sizePolicy.setHeightForWidth(candidatesScrollArea->sizePolicy().hasHeightForWidth());
candidatesScrollArea->setSizePolicy(sizePolicy);
candidatesScrollArea->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
candidatesScrollArea->setWidgetResizable(true);
candidates = new RowedList(font(), false, candidatesScrollArea);
candidatesScrollArea->setWidget(candidates);
candidatesScrollArea->setWidgetResizable(true);
vtLayout->addWidget(candidatesScrollArea);
stmt = createStatement(
"select utf8 from utf8Table join \
kMandarinTable on kMandarinTable.code = utf8Table.code \
where kMandarinTable.kMandarin = ?;");
connect(pinyin, SIGNAL(textEdited(QString)), this, SLOT(searchTermChanged(QString)));
connect(candidates, SIGNAL(characterSelected(QString)), this, SLOT(disambiguated(QString)));
}
示例6: CryptoConfigComponentGUI
void Kleo::CryptoConfigModule::init( Layout layout ) {
Kleo::CryptoConfig * const config = mConfig;
const KPageView::FaceType type=determineJanusFace( config, layout );
setFaceType(type);
QVBoxLayout * vlay = 0;
QWidget * vbox = 0;
if ( type == Plain ) {
vbox = new QWidget(this);
vlay = new QVBoxLayout( vbox );
vlay->setSpacing( KDialog::spacingHint() );
vlay->setMargin( 0 );
addPage( vbox, i18n("GpgConf Error") );
}
const QStringList components = config->componentList();
for ( QStringList::const_iterator it = components.begin(); it != components.end(); ++it ) {
//kDebug(5150) <<"Component" << (*it).toLocal8Bit() <<":";
Kleo::CryptoConfigComponent* comp = config->component( *it );
Q_ASSERT( comp );
if ( comp->groupList().empty() )
continue;
if ( type != Plain ) {
vbox = new QWidget(this);
vlay = new QVBoxLayout( vbox );
vlay->setSpacing( KDialog::spacingHint() );
vlay->setMargin( 0 );
KPageWidgetItem *pageItem = new KPageWidgetItem( vbox, comp->description() );
if ( type != Tabbed )
pageItem->setIcon( loadIcon( comp->iconName() ) );
addPage(pageItem);
}
QScrollArea* scrollArea = type == Tabbed ? new QScrollArea( this ) : new ScrollArea( this );
scrollArea->setWidgetResizable( true );
vlay->addWidget( scrollArea );
CryptoConfigComponentGUI* compGUI =
new CryptoConfigComponentGUI( this, comp, scrollArea );
compGUI->setObjectName( *it );
scrollArea->setWidget( compGUI );
scrollArea->setSizePolicy( QSizePolicy::MinimumExpanding, QSizePolicy::Preferred );
// KJanusWidget doesn't seem to have iterators, so we store a copy...
mComponentGUIs.append( compGUI );
// Set a nice startup size
const int deskHeight = QApplication::desktop()->height();
int dialogHeight;
if (deskHeight > 1000) // very big desktop ?
dialogHeight = 800;
else if (deskHeight > 650) // big desktop ?
dialogHeight = 500;
else // small (800x600, 640x480) desktop
dialogHeight = 400;
assert( scrollArea->widget() );
if ( type != Tabbed )
scrollArea->setMinimumHeight( qMin( compGUI->sizeHint().height(), dialogHeight ) );
}
if ( mComponentGUIs.empty() ) {
const QString msg = i18n("The gpgconf tool used to provide the information "
"for this dialog does not seem to be installed "
"properly. It did not return any components. "
"Try running \"%1\" on the command line for more "
"information.",
components.empty() ? "gpgconf --list-components" : "gpgconf --list-options gpg" );
QLabel * label = new QLabel( msg, vbox );
label->setWordWrap( true);
label->setMinimumHeight( fontMetrics().lineSpacing() * 5 );
vlay->addWidget( label );
}
}
示例7: createWidgets
void CloudDialog::createWidgets()
{
QLabel * label = 0;
bool isConnected = false;
m_amazonProviderWidget = new AmazonProviderWidget(this);
m_blankProviderWidget = new BlankProviderWidget(this);
m_vagrantProviderWidget = new VagrantProviderWidget(this);
// BLANK PAGE
QWidget * blankPageWidget = new QWidget();
// LOGIN PAGE
QHBoxLayout * mainLoginLayout = new QHBoxLayout;
mainLoginLayout->setContentsMargins(QMargins(0,0,0,0));
mainLoginLayout->setSpacing(5);
QWidget * loginPageWidget = new QWidget;
loginPageWidget->setLayout(mainLoginLayout);
// LEFT LOGIN LAYOUT
m_leftLoginLayout = new QVBoxLayout();
mainLoginLayout->addLayout(m_leftLoginLayout);
label = new QLabel;
label->setObjectName("H2");
label->setText("Cloud Resources");
m_leftLoginLayout->addWidget(label,0,Qt::AlignTop | Qt::AlignLeft);
m_cloudResourceComboBox = new QComboBox();
m_leftLoginLayout->addWidget(m_cloudResourceComboBox,0,Qt::AlignTop | Qt::AlignLeft);
//m_cloudResourceComboBox->addItem(NO_PROVIDER);
if(showVagrant()) m_cloudResourceComboBox->addItem(VAGRANT_PROVIDER);
m_cloudResourceComboBox->addItem(AMAZON_PROVIDER);
isConnected = connect(m_cloudResourceComboBox, SIGNAL(currentIndexChanged(const QString &)),
this, SLOT(cloudResourceChanged(const QString &)));
OS_ASSERT(isConnected);
// LOGIN STACKED WIDGET
m_loginStackedWidget = new QStackedWidget();
m_leftLoginLayout->addWidget(m_loginStackedWidget);
m_loginStackedWidget->addWidget(m_blankProviderWidget->m_loginWidget);
m_loginStackedWidget->addWidget(m_vagrantProviderWidget->m_loginWidget);
m_loginStackedWidget->addWidget(m_amazonProviderWidget->m_loginWidget);
m_loginStackedWidget->setCurrentIndex(m_blankProviderIdx);
// RIGHT LOGIN LAYOUT
m_rightLoginLayout = new QVBoxLayout();
mainLoginLayout->addLayout(m_rightLoginLayout);
m_legalAgreement = new QLabel;
m_legalAgreement->hide();
m_legalAgreement->setWordWrap(true);
AWSSettings awsSettings;
m_legalAgreement->setText(awsSettings.userAgreementText().c_str());
QScrollArea * scrollArea = new QScrollArea();
scrollArea->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Expanding);
scrollArea->setFixedWidth(TEXT_WIDTH + 15);
scrollArea->setMinimumHeight(TEXT_HEIGHT);
scrollArea->setStyleSheet("background-color:transparent;");
scrollArea->setWidget(m_legalAgreement);
scrollArea->setWidgetResizable(true);
scrollArea->setAlignment(Qt::AlignTop);
scrollArea->setFrameShape(QFrame::NoFrame);
m_rightLoginLayout->addWidget(scrollArea);
m_iAcceptCheckBox = new QCheckBox("I Agree");
m_iAcceptCheckBox->hide();
m_rightLoginLayout->addWidget(m_iAcceptCheckBox,0,Qt::AlignTop | Qt::AlignLeft);
m_rightLoginLayout->addSpacing(5);
isConnected = connect(m_iAcceptCheckBox, SIGNAL(clicked(bool)),
this, SLOT(iAcceptClicked(bool)));
OS_ASSERT(isConnected);
m_rightLoginLayout->addSpacing(5);
// SETTINGS PAGE
m_mainSettingsLayout = new QVBoxLayout;
m_mainSettingsLayout->setContentsMargins(QMargins(0,0,0,0));
m_mainSettingsLayout->setSpacing(5);
QWidget * settingsPageWidget = new QWidget;
settingsPageWidget->setLayout(m_mainSettingsLayout);
// SETTINGS STACKED WIDGET
m_settingsStackedWidget = new QStackedWidget();
//.........这里部分代码省略.........
示例8: setup
// Setup widget
void MyWidget::setup(int layoutMargin, QString borderColor, QString backgroundColor) {
// Some styling
visibleArea = QSize(600,400);
this->borderColor = borderColor;
this->backgroundColor = (backgroundColor == "" ? "rgba(0,0,0,200)" : backgroundColor);
borderLeftRight = -1;
borderTopDown = -1;
fullscreen = false;
// The different QRects
rectShown = QRect();
rectHidden = QRect(0,-10,10,10);
rectAni = QRect();
// The current geometry and position
isShown = false;
this->setGeometry(rectHidden);
// Fading
backOpacityShow = 0.5;
backOpacityCur = 0;
centerOpacityCur = 0;
fade = new QTimeLine;
fadeIN = true;
fadeEffectCenter = new QGraphicsOpacityEffect;
connect(fade, SIGNAL(valueChanged(qreal)), this, SLOT(fadeStep()));
connect(fade, SIGNAL(finished()), this, SLOT(aniFinished()));
// The current widget look
this->setStyleSheet(QString("background: rgba(0,0,0,%1);").arg(255*backOpacityShow));
// the central widget containing all the information
center = new QWidget(this);
center->setGraphicsEffect(fadeEffectCenter);
center->setObjectName("center");
// For some reason, if the border is not defined right here at the beginning, it wont be visible...
if(borderColor == "")
center->setStyleSheet(QString("#center { background: %1; border-radius: 10px; font-size: 12pt; }").arg(this->backgroundColor));
else
center->setStyleSheet(QString("#center {background: %1; border-radius: 15px; font-size: 12pt; border: 2px solid %2; }").arg(this->backgroundColor).arg(borderColor));
// Create and set the scrollarea with main layout
QVBoxLayout *central = new QVBoxLayout;
central->setMargin(layoutMargin);
QScrollArea *scroll = new QScrollArea(this);
scroll->setObjectName("scrollWidget");
scroll->setStyleSheet("QWidget#scrollWidget { background: transparent; padding-bottom: 3px; border-radius: 0px; }");
QWidget *scrollWidget = new QWidget(scroll->widget());
scrollWidget->setStyleSheet("background: transparent;");
scroll->setWidgetResizable(true);
scroll->setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding);
scrollWidget->setLayout(central);
scroll->setWidget(scrollWidget);
mainlayout = new QVBoxLayout;
if(layoutMargin == 0) mainlayout->setMargin(0);
center->setLayout(mainlayout);
mainlayout->addWidget(scroll);
// This widget gets the main layout set to
centralWidget = new QWidget;
central->addWidget(centralWidget);
// And set the custom scrollbar
scrollbar = new CustomScrollbar;
scroll->setVerticalScrollBar(scrollbar);
// And in case the monitor resolution is so small, that the horizontal scrollbar is visible:
CustomScrollbar *scrollbarHor = new CustomScrollbar;
scroll->setHorizontalScrollBar(scrollbarHor);
}
示例9: ParamChoice
MainWindow::MainWindow() {
setupUi(this);
m_dirty = false;
m_logWindow->setVisible(false);
m_imageView->setFocus();
m_imageView->setHandler(this);
ParamGroup *g, *gg;
new ParamChoice(this, "output", "edges", "edges|fill|fill+edges", &output);
new ParamChoice(this, "input_gamma", "linear-rgb", "srgb|linear-rgb", &input_gamma);
g = new ParamGroup(this, "structure_tensor");
new ParamChoice(g, "st_type", "scharr-lab", "central-diff|sobel-rgb|sobel-lab|sobel-L|scharr-rgb|scharr-lab|gaussian-deriv|etf-full|etf-xy", &st_type);
new ParamDouble(g, "sigma_c", 2.28, 0, 20, 0.1, &sigma_c);
new ParamDouble(g, "precision_sigma_c", sqrt(-2*log(0.05)), 1, 10, 1, &precision_sigma_c);
new ParamInt (g, "etf_N", 3, 0, 10, 1, &etf_N);
g = new ParamGroup(this, "bilateral_filter", false, &enable_bf);
new ParamChoice(g, "type", "xy", "oa|xy|fbl|full", &filter_type);
new ParamInt (g, "n_e", 1, 0, 20, 1, &n_e);
new ParamInt (g, "n_a", 4, 0, 20, 1, &n_a);
new ParamDouble(g, "sigma_dg", 3, 0, 20, 0.05, &sigma_dg);
new ParamDouble(g, "sigma_dt", 3, 0, 20, 0.05, &sigma_dt);
new ParamDouble(g, "sigma_rg", 4.25, 0, 100, 0.05, &sigma_rg);
new ParamDouble(g, "sigma_rt", 4.25, 0, 100, 0.05, &sigma_rt);
new ParamDouble(g, "bf_alpha", 0, 0, 10000, 1, &bf_alpha);
new ParamDouble(g, "precision_g", 2, 1, 10, 1, &precision_g);
new ParamDouble(g, "precision_t", 2, 1, 10, 1, &precision_t);
g = new ParamGroup(this, "dog");
ParamGroup* dog_group = g;
connect(g, SIGNAL(dirty()), SLOT(dogChanged()));
new ParamChoice(g, "type", "flow-based", "isotropic|flow-based", &dog_type);
new ParamDouble(g, "sigma_e", 1.4, 0, 20, 0.005, &sigma_e);
new ParamDouble(g, "dog_k", 1.6, 1, 10, 0.01, &dog_k);
new ParamDouble(g, "precision_e", 3, 1, 5, 0.1, &precision_e);
new ParamDouble(g, "sigma_m", 4.4, 0, 20, 1, &sigma_m);
new ParamDouble(g, "precision_m", 2, 1, 5, 0.1, &precision_m);
new ParamDouble(g, "step_m", 1, 0.01, 2, 0.1, &step_m);
new ParamChoice(g, "adj_func", "smoothstep", "smoothstep|tanh", &dog_adj_func);
new ParamBool (g, "dog_reparam", true, &dog_reparam);
gg = new ParamGroup(g, "", true);
dog_tau_g = gg;
dog_eps_ptr = new ParamDouble(gg, "epsilon", 3.50220, -100, 100, 0.005, &dog_eps);
dog_tau_ptr = new ParamDouble(gg, "tau", 0.95595, 0, 2, 0.005, &dog_tau);
dog_phi_ptr = new ParamDouble(gg, "phi", 0.3859, 0, 1e32, 0.1, &dog_phi);
gg = new ParamGroup(g, "", false);
dog_p_g = gg;
dog_p_ptr = new ParamDouble(gg, "p", 21.7, 0, 1e6, 1, &dog_p);
dog_eps_p_ptr = new ParamDouble(gg, "epsilon_p", 79.5, -1e32, 1e32, 0.5, &dog_eps_p);
dog_phi_p_ptr = new ParamDouble(gg, "phi_p", 0.017, -1e32, 1e32, 0.05, &dog_phi_p);
new ParamChoice(g, "dog_fgauss", "euler", "euler|rk2-nn|rk2|rk4", &dog_fgauss);
g = new ParamGroup(this, "quantization", false, &quantization);
new ParamChoice(g, "quant_type", "adaptive", "fixed|adaptive", &quant_type);
new ParamInt (g, "nbins", 8, 1, 255, 1, &nbins);
new ParamDouble(g, "phi_q", 2, 0, 100, 0.025, &phi_q);
new ParamDouble(g, "lambda_delta", 0, 0, 100, 1, &lambda_delta);
new ParamDouble(g, "omega_delta", 2, 0, 100, 1, &omega_delta);
new ParamDouble(g, "lambda_phi", 0.9, 0, 100, 1, &lambda_phi);
new ParamDouble(g, "omega_phi", 1.6, 0, 100, 1, &omega_phi);
g = new ParamGroup(this, "warp_sharp", false, &warp_sharp);
new ParamDouble(g, "sigma_w", 1.5, 0, 20, 1, &sigma_w);
new ParamDouble(g, "precision_w", 2, 1, 5, 0.1, &precision_w);
new ParamDouble(g, "phi_w", 2.7, 0, 100, 0.025, &phi_w);
g = new ParamGroup(this, "final_smooth", true, &final_smooth);
new ParamChoice(g, "type", "flow-nearest", "3x3|5x5|flow-nearest|flow-linear", &final_type);
new ParamDouble(g, "sigma_a", 1.0, 0, 10, 1, &sigma_a);
QScrollArea *sa = new QScrollArea(this);
QWidget *parea = new QWidget(sa);
sa->setSizePolicy(QSizePolicy::Fixed,QSizePolicy::Expanding);
sa->setFixedWidth(300);
sa->setWidget(parea);
sa->setFrameStyle(QFrame::NoFrame);
sa->setFocusPolicy(Qt::NoFocus);
sa->setWidgetResizable(true);
sa->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn);
m_vbox1->addWidget(sa);
m_paramui = new ParamUI(parea, this);
QVBoxLayout *pbox = new QVBoxLayout(parea);
pbox->setContentsMargins(4,4,4,4);
pbox->addWidget(m_paramui);
pbox->addStretch(0);
connect(m_select, SIGNAL(currentIndexChanged(int)), this, SLOT(onIndexChanged(int)));
m_player = new VideoPlayer(this, ":/test.png");
connect(m_player, SIGNAL(videoChanged(int)), this, SLOT(onVideoChanged(int)));
connect(m_player, SIGNAL(currentFrameChanged(int)), this, SLOT(setDirty()));
connect(m_player, SIGNAL(outputChanged(const QImage&)), m_imageView, SLOT(setImage(const QImage&)));
//.........这里部分代码省略.........
示例10: QMainWindow
//.........这里部分代码省略.........
// Hitting filter group
QActionGroup* hittingFilters = new QActionGroup(this);
hittingFilters->setExclusive(false);
// Filter helper
auto MakeHitterFilter = [=](QString text, QString toolTip, const auto& onFilterFn) -> QAction*
{
QAction* action = new QAction(this);
connect(action, &QAction::toggled, hitterSortFilterProxyModel, onFilterFn);
action->setText(text);
action->setToolTip(toolTip);
action->setCheckable(true);
action->toggle();
hittingFilters->addAction(action);
return action;
};
// Hitter filters
QAction* filterC = MakeHitterFilter("C", "Filter Catchers", &PlayerSortFilterProxyModel::OnFilterC);
QAction* filter1B = MakeHitterFilter("1B", "Filter 1B", &PlayerSortFilterProxyModel::OnFilter1B);
QAction* filter2B = MakeHitterFilter("2B", "Filter 2B", &PlayerSortFilterProxyModel::OnFilter2B);
QAction* filterSS = MakeHitterFilter("SS", "Filter SS", &PlayerSortFilterProxyModel::OnFilterSS);
QAction* filter3B = MakeHitterFilter("3B", "Filter 3B", &PlayerSortFilterProxyModel::OnFilter3B);
QAction* filterOF = MakeHitterFilter("OF", "Filter Outfielders", &PlayerSortFilterProxyModel::OnFilterOF);
QAction* filterCI = MakeHitterFilter("CI", "Filter Corner Infielders", &PlayerSortFilterProxyModel::OnFilterCI);
QAction* filterMI = MakeHitterFilter("MI", "Filter Middle Infielders", &PlayerSortFilterProxyModel::OnFilterMI);
QAction* filterDH = MakeHitterFilter("DH", "Filter Designated Hitters", &PlayerSortFilterProxyModel::OnFilterDH);
QAction* filterU = MakeHitterFilter("U", "Filter Utility", &PlayerSortFilterProxyModel::OnFilterU);
// Menu spacer
QWidget* spacer = new QWidget(this);
spacer->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
// Completion Widget
QCompleter* completer = new QCompleter(this);
completer->setModel(playerTableModel);
completer->setCompletionColumn(PlayerTableModel::COLUMN_NAME);
completer->setFilterMode(Qt::MatchContains);
completer->setCaseSensitivity(Qt::CaseInsensitive);
// Select
auto HighlightPlayerInTable = [=](const QModelIndex& srcIdx)
{
// Lookup catergory
auto catergoryIdx = srcIdx.model()->index(srcIdx.row(), PlayerTableModel::COLUMN_CATERGORY);
auto catergory = srcIdx.model()->data(catergoryIdx).toUInt();
// Change to tab
hitterPitcherTabs->setCurrentIndex(CaterogyToTab(catergory));
// Select row
if (catergory == Player::Catergory::Hitter) {
auto proxyModel = dynamic_cast<QSortFilterProxyModel*>(hitterTableView->model());
auto proxyIdx = proxyModel->mapFromSource(srcIdx);
hitterTableView->selectRow(proxyIdx.row());
hitterTableView->setFocus();
} else if (catergory == Player::Catergory::Pitcher) {
auto proxyModel = dynamic_cast<QSortFilterProxyModel*>(pitcherTableView->model());
auto proxyIdx = proxyModel->mapFromSource(srcIdx);
pitcherTableView->selectRow(proxyIdx.row());
pitcherTableView->setFocus();
}
};
示例11: init
void MainPanel::init()
{
if (!db.init())
{
QMessageBox error;
error.critical(0, "Error!", "An error occured while trying to load the database.");
exit(EXIT_FAILURE);
return;
}
stack = new QStackedWidget(this);
QString style = getStylesheet(":/Styles/Content.css");
// Prepare UI objects for each tab
libraryPtr = new Library(db);
libraryPtr->setStyleSheet(style);
browserPtr = new Browser();
browserPtr->setStyleSheet(style);
stack->addWidget(libraryPtr);
stack->addWidget(browserPtr);
stack->setCurrentWidget(libraryPtr);
// System layout
QHBoxLayout* systemLayout = new QHBoxLayout;
systemLayout->setSpacing(0);
systemLayout->setMargin(8);
// Header spacing
QVBoxLayout* topLayout = new QVBoxLayout;
topLayout->setMargin(0);
// Header layout
QHBoxLayout* headerLayout = new QHBoxLayout;
headerLayout->setSpacing(0);
headerLayout->setMargin(0);
// Window title
QLabel* windowTitle = new QLabel(this);
windowTitle->setObjectName("windowTitle");
windowTitle->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
windowTitle->setMinimumWidth(175);
windowTitle->setMaximumWidth(175);
windowTitle->setAlignment(Qt::AlignTop);
windowTitle->setFont(QFont("Sansation", 18));
windowTitle->setText("Project \nASCENSION");
windowTitle->setStyleSheet("color: #7D818C;");
windowTitle->setAttribute(Qt::WA_TransparentForMouseEvents);
// Post-initialization header spacing
topLayout->addLayout(systemLayout);
topLayout->addLayout(headerLayout);
topLayout->addSpacing(10);
headerLayout->addSpacing(20);
headerLayout->addWidget(windowTitle);
headerLayout->addSpacing(40);
// Header tabs
libraryTab = new TabLabel(this);
libraryTab = g_tabFactory(libraryTab, "libraryTab", "LIBRARY");
headerLayout->addSpacing(8);
headerLayout->addWidget(libraryTab);
libraryTab->setStyleSheet("font-weight: bold; color: lightgreen;");
storeTab = new TabLabel(this);
storeTab = g_tabFactory(storeTab, "storeTab", " STORE");
headerLayout->addSpacing(8);
headerLayout->addWidget(storeTab);
modsTab = new TabLabel(this);
modsTab = g_tabFactory(modsTab, "modsTab", " MODS");
headerLayout->addSpacing(8);
headerLayout->addWidget(modsTab);
newsTab = new TabLabel(this);
newsTab = g_tabFactory(newsTab, "newsTab", "NEWS");
headerLayout->addSpacing(8);
headerLayout->addWidget(newsTab);
browserTab = new TabLabel(this);
browserTab = g_tabFactory(browserTab, "browserTab", "BROWSER");
headerLayout->addSpacing(8);
headerLayout->addWidget(browserTab);
activeTab = libraryTab;
headerLayout->addStretch();
// System buttons
systemLayout->addStretch();
// Minimize
QPushButton* pushButtonMinimize = new QPushButton("", this);
pushButtonMinimize->setObjectName("pushButtonMinimize");
systemLayout->addWidget(pushButtonMinimize);
QObject::connect(pushButtonMinimize, SIGNAL(clicked()), this, SLOT(pushButtonMinimize()));
// Maximize
QPushButton* pushButtonMaximize = new QPushButton("", this);
pushButtonMaximize->setObjectName("pushButtonMaximize");
//.........这里部分代码省略.........