本文整理汇总了C++中QScrollArea::viewport方法的典型用法代码示例。如果您正苦于以下问题:C++ QScrollArea::viewport方法的具体用法?C++ QScrollArea::viewport怎么用?C++ QScrollArea::viewport使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QScrollArea
的用法示例。
在下文中一共展示了QScrollArea::viewport方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: QMdiSubWindow
/*!
\brief Constructor.
Creates a new instance of ProjectWindow.
\param pro project data to show, not null.
\param parent parent widgets of this window, default value is 0.
*/
Ui::ProjectWindow::ProjectWindow(Core::Project *pro, QWidget *parent /* = 0 */)
: QMdiSubWindow(parent),
project(pro)
{
// entry conditions
Q_CHECK_PTR(pro);
setAttribute(Qt::WA_DeleteOnClose);
setWindowIcon(QIcon(":/proj"));
setWindowTitle(project->name());
setMinimumSize(200, 200);
// project view, the main widget
view = new ProjectView(this);
scene = new ProjectScene(project, this);
view->setScene(scene);
view->setSceneRect(0, 0, project->width(), project->height());
QScrollArea* centerPanel = new QScrollArea(this);
centerPanel->viewport()->setStyleSheet(QString("background-color:#C0C0C0"));
centerPanel->setAlignment(Qt::AlignCenter);
centerPanel->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn);
centerPanel->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
centerPanel->setWidget(view);
// status bar
statusBar = new QWidget(this);
QHBoxLayout *statusLayout = new QHBoxLayout(statusBar);
statusLayout->setMargin(0);
statusBar->setLayout(statusLayout);
QLineEdit* percentInput = new QLineEdit(statusBar);
percentInput->setText("100");
percentInput->setFixedSize(40, 18);
QLabel *msgLabel = new QLabel(statusBar);
msgLabel->setText("%");
msgLabel->setFixedWidth(8);
QPushButton *gridButton = new QPushButton(statusBar);
gridButton->setText("#");
gridButton->setCheckable(true);
gridButton->setFixedSize(20, 18);
QLabel *ctrlLabel = new QLabel(statusBar);
ctrlLabel->setFixedWidth(qApp->style()->pixelMetric(QStyle::PM_ScrollBarExtent) - 6);
statusLayout->addWidget(percentInput);
statusLayout->addWidget(msgLabel);
statusLayout->addWidget(gridButton);
statusLayout->addWidget(centerPanel->horizontalScrollBar(), 100);
statusLayout->addWidget(ctrlLabel);
QWidget *mainPanel = new QWidget(this);
QVBoxLayout *mainLayout = new QVBoxLayout;
mainLayout->setMargin(0);
mainLayout->setSpacing(0);
mainLayout->addWidget(centerPanel);
mainLayout->addWidget(statusBar);
mainPanel->setLayout(mainLayout);
setWidget(mainPanel);
connect(gridButton, SIGNAL(clicked(bool)), scene, SLOT(showGrid(bool)));
connect(appCtx->mainWindow(), SIGNAL(antialiasingChanged(bool)), scene, SLOT(setAntialiasing(bool)));
}
示例2: QVERIFY
void tst_QScrollArea::ensureMicroFocusVisible_Task_167838()
{
QScrollArea scrollArea;
scrollArea.resize(100, 100);
scrollArea.show();
QWidget *parent = new QWidget;
parent->setLayout(new QVBoxLayout);
QWidget *child = new WidgetWithMicroFocus;
parent->layout()->addWidget(child);
parent->resize(300, 300);
scrollArea.setWidget(parent);
scrollArea.ensureWidgetVisible(child, 10, 10);
QRect microFocus = child->inputMethodQuery(Qt::ImMicroFocus).toRect();
QPoint p = child->mapTo(scrollArea.viewport(), microFocus.topLeft());
microFocus.translate(p - microFocus.topLeft());
QVERIFY(scrollArea.viewport()->rect().contains(microFocus));
}
示例3: main
int main(int argc, char *argv[])
{
application app(argc, argv);
icon_editor* editor = new icon_editor;
editor->set_icon_image(QImage(":/icon_editor_images/mouse.png"));
QScrollArea area;
area.setWidget(editor);
area.setWidgetResizable(true);
area.setFocusPolicy(Qt::NoFocus);
area.viewport()->setBackgroundRole(QPalette::Dark);
area.viewport()->setAutoFillBackground(true);
area.setWindowTitle(QObject::tr("Icon Editor"));
editor->setFocus(Qt::OtherFocusReason); // TODO: simpler way of focusing scroll area's widget?
area.show();
return app.exec();
}
示例4: QAbstractPageWidget
QProjectWidget::QProjectWidget(QWidget * parent):
QAbstractPageWidget(parent),
m_projectPropertyView(new QPropertyListView(this)),
m_projectBar(new StyledBar(this)),
m_pageView(new QPageView(this)),
m_pageViewBar(new StyledBar(this))
{
QVBoxLayout *vl = new QVBoxLayout;
MiniSplitter *sp = new MiniSplitter;
vl->setMargin(0);
vl->addWidget(sp);
setLayout(vl);
QWidget* wid = new QWidget;
sp->addWidget(wid);
vl = new QVBoxLayout;
vl->setMargin(0);
vl->setSpacing(0);
vl->addWidget(m_projectBar);
vl->addWidget(m_projectPropertyView);
wid->setLayout(vl);
QScrollArea * pagePane = new QScrollArea;
pagePane->setWidget(m_pageView);
pagePane->setFrameStyle(QFrame::NoFrame);
pagePane->viewport()->setStyleSheet("background-color:rgb(255,255,255);");
wid = new QWidget;
vl = new QVBoxLayout;
vl->setMargin(0);
vl->setSpacing(0);
vl->addWidget(m_pageViewBar);
vl->addWidget(pagePane);
wid->setLayout(vl);
sp->addWidget(wid);
sp->setStretchFactor(0,0);
sp->setStretchFactor(1,1);
connect(QSoftCore::getInstance()->getProject(),SIGNAL(hostAdded(QAbstractWidgetHost*,int)),
m_pageView,SLOT(addHost(QAbstractWidgetHost*,int)));
}
示例5: QWidget
QwwTaskPanel::QwwTaskPanel(QWidget *parent) : QWidget(parent)
/*: QScrollArea(parent)*/ {
QScrollArea *sa = new QScrollArea(this);
QVBoxLayout *la = new QVBoxLayout(this);
la->setMargin(0);
la->addWidget(sa);
m_animated = false;
m_panel = new QWidget(sa->viewport());
m_panel->setSizePolicy(QSizePolicy::Ignored, QSizePolicy::MinimumExpanding);
m_panel->setObjectName("ww_taskpanel_panel");
m_current = -1;
QVBoxLayout *l = new QVBoxLayout(m_panel);
l->addStretch();
sa->setWidget(m_panel);
sa->setWidgetResizable(true);
setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Expanding);
}
示例6: addModule
void ModuleView::addModule( KCModuleInfo *module )
{
if( !module ) {
return;
}
if( !module->service() ) {
qWarning() << "ModuleInfo has no associated KService" ;
return;
}
if ( !KAuthorized::authorizeControlModule( module->service()->menuId() ) ) {
qWarning() << "Not authorised to load module" ;
return;
}
if( module->service()->noDisplay() ) {
return;
}
// Create the scroller
QScrollArea * moduleScroll = new QScrollArea( this );
// Prepare the scroll area
moduleScroll->setWidgetResizable( true );
moduleScroll->setFrameStyle( QFrame::NoFrame );
moduleScroll->viewport()->setAutoFillBackground( false );
// Create the page
KPageWidgetItem *page = new KPageWidgetItem( moduleScroll, module->moduleName() );
// Provide information to the users
KCModuleProxy * moduleProxy = new KCModuleProxy( *module, moduleScroll );
moduleScroll->setWidget( moduleProxy );
moduleProxy->setAutoFillBackground( false );
connect( moduleProxy, SIGNAL(changed(bool)), this, SLOT(stateChanged()));
d->mPages.insert( page, moduleProxy );
d->mModules.insert( page, module );
updatePageIconHeader( page, true );
// Add the new page
d->mPageWidget->addPage( page );
}
示例7: createPlotSettingsView
void MainWindow::createPlotSettingsView()
{
groupSettings = new GroupSettings(this);
plotSettings = new PlotSettings(this);
{
QScrollArea* scroller = new QScrollArea(this);
QVBoxLayout* content = new QVBoxLayout(scroller->viewport());
content->setMargin(0);
content->setSpacing(0);
content->addWidget(groupSettings);
content->addWidget(plotSettings);
ui->commonSettings->setWidget(scroller);
}
{
connect(groupSettings, SIGNAL(groupNameWasChanged()), groups, SLOT(retitle()));
connect(groups, SIGNAL(groupChanged(Group*)), groupSettings, SLOT(catchGroup(Group*)));
connect(groups, SIGNAL(noMoreGroup()), groupSettings, SLOT(freeGroup()));
connect(groups, SIGNAL(wasActivated(QMdiSubWindow*)), plotSettings, SLOT(catchPlot(QMdiSubWindow*)));
connect(groups, SIGNAL(noMoreGroup()), plotSettings, SLOT(toDefaultState()));
connect(groups, SIGNAL(noMorePlots()), plotSettings, SLOT(toDefaultState()));
connect(plotSettings, SIGNAL(copySettings(PlotSettingsFiller*)), groups, SLOT(copySettingsToActiveGroup(PlotSettingsFiller*)));
}
}
示例8: main
//.........这里部分代码省略.........
int flag=0,flag1=0;
FILE* fp;
fp=fopen("counter.txt","r");
if(fp==NULL)
{
flag=1;
}
else
fclose(fp);
if(flag==1)
{
int k=1;
fp=fopen("counter.txt","w");
fprintf(fp,"%i",k);
fclose(fp);
}
else
{
iput.open("counter.txt");
int count;
iput>>count;
iput.close();
if(count>=updateCounter)
{
// callFileList();
flag1=1;
count=-1;
}
count++;
fp=fopen("counter.txt","w+");
fprintf(fp,"%i",count);
fclose(fp);
}
if(flag1==1 || flag==1)
{
fileList f1;
f1.runner();
}
/********************Reading files in Prefix -trie********************************/
Btree b1;
b1.takeInput(str1);
tries t2;
callPrefixTrie(t2);
/*************************history trie*****************************************/
tries t1;
callHistoryTrie(t1);
/**************************************************************/
string str;
cout<<"enter the string :"<<endl;
//cin>>str;
//vector<fax*> inputVector;
//inputVector=process(str,t2,t1,n);
/* for(int i=0;i<star.size();i++)
{
cout<<star[i]->nam<<endl;
}
*/
/* fax* fax1=new fax("rhythmbox-client","##");
show(fax1,t2,t1);
onClose(t1);
*/
//##########################################################################3
w->startArena(t1,t2, 15);
QScrollArea scrollarea;
scrollarea.setWidget(w);
scrollarea.setWidgetResizable(true);
scrollarea.viewport()->setBackgroundRole(QPalette::Dark);
scrollarea.viewport()->setAutoFillBackground(true);
scrollarea.setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOn);
scrollarea.setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn);
scrollarea.setWindowTitle(QObject::tr("arena"));
scrollarea.show();
//w->show();
return a.exec();
}
示例9: continueCreate
/// continue the creation of the widgets once the pieces XML was loaded.
/// this is where all the work of creating the family tabs and their content is performed.
void PicsSelectWidget::continueCreate()
{
const PicBucket& bucket = PicBucket::instance();
m_tabs = new QTabWidget(this);
connect(m_tabs, SIGNAL(currentChanged(int)), this, SLOT(updateSetsSpinBox(int)));
m_layout->addWidget(m_tabs);
m_groups.resize(bucket.grps.size());
for (int f = 0; f < bucket.families.size(); ++f)
{
const PicFamily &fam = bucket.families[f];
SizedWidget *tab = new SizedWidget(QSize(6 * BOT_TOTAL_X + BOT_OFFS_X + FRAME_OFFS_SPACE_RIGHT - 5, NUM_DEFS * BOT_TOTAL_Y + FRAME_OFFS_Y), nullptr);
//QWidget *tab = new QWidget();
//tab->resize(QSize(6 * BOT_TOTAL_X + BOT_OFFS_X + FRAME_OFFS_SPACE_RIGHT, NUM_DEFS * BOT_TOTAL_Y + FRAME_OFFS_Y));
QScrollArea *scroll = new QScrollArea();
scroll->setWidget(tab);
// the following is the voodoo needed to make the scroll area the same color as the tab
// if this wasn't here, the scroll area would have gotten the default window color
// this is significant in Windows XP with new apperance style where the tab color is
// different from the default window color
scroll->viewport()->setAutoFillBackground(false);
tab->setAutoFillBackground(false);
// scroll area has a frame by default. get rid of it.
scroll->setFrameShape(QFrame::NoFrame);
m_tabs->addTab(scroll, fam.name.c_str());
for (int g = fam.startIndex; g < fam.startIndex + fam.numGroups; ++g)
{
const PicGroupDef *grp = &(bucket.grps[g]);
GroupCtrl &grpctrl = m_groups[g];
int normg = (g - fam.startIndex); // normalized g with start of family
QGroupBox *groupbox = new QGroupBox(grp->name.c_str(), tab);
groupbox->move(BOT_OFFS_X-FRAME_OFFS_SPACE_LEFT, FRAME_OFFS_Y + normg*BOT_TOTAL_Y - 30);
groupbox->resize(FRAME_OFFS_SPACE_RIGHT + grp->numPics() * BOT_TOTAL_X, BOT_Y + 55);
grpctrl.num = new DataSpinBox(g, tab);
grpctrl.num->move(grp->numPics() * BOT_TOTAL_X + BOT_OFFS_X + FRAME_OFFS_SPACE_RIGHT - 65, BOT_OFFS_Y + normg*BOT_TOTAL_Y + 40);
grpctrl.num->resize(45, 23);
grpctrl.num->setButtonSymbols(QAbstractSpinBox::PlusMinus);
grpctrl.num->setRange(-1, MAX_IDENTICAL_PIECES);
grpctrl.num->setSpecialValueText("X");
connect(grpctrl.num, SIGNAL(dvalueChanged(int, int)), this, SLOT(changedGrpBox(int, int)));
for (int p = 0; p < bucket.grps[g].numPics(); ++p)
{
const PicDef* pic = &(grp->getPic(p));
PicCtrl picctrl;
int data = (g << 16) | p;
DataPushButton *button = new DataPushButton(data, QIcon(pic->pixmap), QString(), tab);
picctrl.bot = button;
button->setCheckable(true);
button->move(BOT_OFFS_X + p*BOT_TOTAL_X, BOT_OFFS_Y + normg * BOT_TOTAL_Y); // g normalized to start of family
button->resize(BOT_X, BOT_Y);
button->setIconSize(pic->pixmap.size()); // +1 because it's the texture + line, from Pieces.h
connect(button, SIGNAL(pclicked(int, bool)), this, SLOT(pressedPicButton(int, bool)));
DataSpinBox *spinbox = new DataSpinBox(data, tab);
picctrl.num = spinbox;
spinbox->setRange(0, MAX_IDENTICAL_PIECES);
spinbox->move(BOT_OFFS_X + p*BOT_TOTAL_X + (BOT_X/5*2 + 2), BOT_OFFS_Y + normg*BOT_TOTAL_Y + BOT_Y + 5);
spinbox->resize(BOT_X/5*3 - 4, EDIT_THICK + 1);
spinbox->setButtonSymbols(QAbstractSpinBox::PlusMinus);
connect(spinbox, SIGNAL(dvalueChanged(int, int)), this, SLOT(changedNumBox(int, int)));
QLabel *solnum = new QLabel("0", tab);
picctrl.snum = solnum;
solnum->move(BOT_OFFS_X + p*BOT_TOTAL_X + 2, BOT_OFFS_Y + normg*BOT_TOTAL_Y + BOT_Y + 6);
solnum->resize(BOT_X/5*2 - 4, EDIT_THICK);
solnum->setAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
solnum->setFrameShadow(QFrame::Sunken);
solnum->setFrameShape(QFrame::Panel);
solnum->setPalette(*m_slvPalette);
solnum->setVisible(false);
grpctrl.pics.push_back(picctrl);
}
}
}
setBuildTilesCount(m_doc->getBuild().tilesCount());
// prevent the build Help sidebar to get notifications. it might not be there yet.
// eventually the sidebar will take care of itself.
blockSignals(true);
changeToResetValues();
//.........这里部分代码省略.........
示例10: QWidget
SettingsPageUnits::SettingsPageUnits(QWidget *parent) : QWidget(parent)
{
setObjectName("SettingsPageUnits");
setWindowFlags( Qt::Tool );
setWindowModality( Qt::WindowModal );
setAttribute(Qt::WA_DeleteOnClose);
setWindowTitle( tr("Settings - Units") );
if( parent )
{
resize( parent->size() );
}
// Layout used by scroll area
QHBoxLayout *sal = new QHBoxLayout;
// new widget used as container for the dialog layout.
QWidget* sw = new QWidget;
// Scroll area
QScrollArea* sa = new QScrollArea;
sa->setWidgetResizable( true );
sa->setFrameStyle( QFrame::NoFrame );
sa->setWidget( sw );
#ifdef ANDROID
QScrollBar* lvsb = sa->verticalScrollBar();
lvsb->setStyleSheet( Layout::getCbSbStyle() );
#endif
#ifdef QSCROLLER
QScroller::grabGesture( sa->viewport(), QScroller::LeftMouseButtonGesture );
#endif
#ifdef QTSCROLLER
QtScroller::grabGesture( sa->viewport(), QtScroller::LeftMouseButtonGesture );
#endif
// Add scroll area to its own layout
sal->addWidget( sa );
QHBoxLayout *contentLayout = new QHBoxLayout;
setLayout(contentLayout);
// Pass scroll area layout to the content layout.
contentLayout->addLayout( sal, 10 );
// The parent of the layout is the scroll widget
QGridLayout *topLayout = new QGridLayout(sw);
int row=0;
QLabel *label = new QLabel(tr("Altitude:"), this);
topLayout->addWidget(label, row, 0);
UnitAlt = new QComboBox(this);
UnitAlt->setObjectName("UnitAlt");
UnitAlt->setEditable(false);
topLayout->addWidget(UnitAlt,row++,1);
UnitAlt->addItem(tr("meters"));
UnitAlt->addItem(tr("feet"));
altitudes[0] = int(Altitude::meters);
altitudes[1] = int(Altitude::feet);
label = new QLabel(tr("Speed:"), this);
topLayout->addWidget(label, row, 0);
UnitSpeed = new QComboBox(this);
UnitSpeed->setObjectName("UnitSpeed");
UnitSpeed->setEditable(false);
topLayout->addWidget(UnitSpeed,row++,1);
UnitSpeed->addItem(tr("meters per second"));
UnitSpeed->addItem(tr("kilometers per hour"));
UnitSpeed->addItem(tr("knots"));
UnitSpeed->addItem(tr("miles per hour"));
speeds[0] = Speed::metersPerSecond;
speeds[1] = Speed::kilometersPerHour;
speeds[2] = Speed::knots;
speeds[3] = Speed::milesPerHour;
label = new QLabel(tr("Distance:"), this);
topLayout->addWidget(label, row, 0);
UnitDistance = new QComboBox(this);
UnitDistance->setObjectName("UnitDistance");
UnitDistance->setEditable(false);
topLayout->addWidget(UnitDistance,row++,1);
UnitDistance->addItem(tr("kilometers"));
UnitDistance->addItem(tr("statute miles"));
UnitDistance->addItem(tr("nautical miles"));
distances[0] = Distance::kilometers;
distances[1] = Distance::miles;
distances[2] = Distance::nautmiles;
label = new QLabel(tr("Vario:"), this);
topLayout->addWidget(label, row, 0);
UnitVario = new QComboBox(this);
UnitVario->setObjectName("UnitVario");
UnitVario->setEditable(false);
topLayout->addWidget(UnitVario,row++,1);
UnitVario->addItem(tr("meters per second"));
UnitVario->addItem(tr("feet per minute"));
UnitVario->addItem(tr("knots"));
//.........这里部分代码省略.........
示例11: pixmap
SettingsPageTerrainColors::SettingsPageTerrainColors(QWidget *parent) :
QWidget(parent),
colorsChanged(false),
m_autoSip( true )
{
setObjectName("SettingsPageTerrainColors");
setWindowFlags( Qt::Tool );
setWindowModality( Qt::WindowModal );
setAttribute(Qt::WA_DeleteOnClose);
setWindowTitle( tr("Settings - Terrain Colors") );
if( parent )
{
resize( parent->size() );
}
// Layout used by scroll area
QHBoxLayout *sal = new QHBoxLayout;
// new widget used as container for the dialog layout.
QWidget* sw = new QWidget;
// Scroll area
QScrollArea* sa = new QScrollArea;
sa->setWidgetResizable( true );
sa->setFrameStyle( QFrame::NoFrame );
sa->setWidget( sw );
#ifdef QSCROLLER
QScroller::grabGesture( sa->viewport(), QScroller::LeftMouseButtonGesture );
#endif
#ifdef QTSCROLLER
QtScroller::grabGesture( sa->viewport(), QtScroller::LeftMouseButtonGesture );
#endif
// Add scroll area to its own layout
sal->addWidget( sa );
QHBoxLayout *contentLayout = new QHBoxLayout(this);
// Pass scroll area layout to the content layout.
contentLayout->addLayout( sal );
/**
* Altitude levels in meters to be displayed in color combo box.
*/
const char *altitudes[51] = {
"< 0",
"0",
"10",
"25",
"50",
"75",
"100",
"150",
"200",
"250",
"300",
"350",
"400",
"450",
"500",
"600",
"700",
"800",
"900",
"1000",
"1250",
"1500",
"1750",
"2000",
"2250",
"2500",
"2750",
"3000",
"3250",
"3500",
"3750",
"4000",
"4250",
"4500",
"4750",
"5000",
"5250",
"5500",
"5750",
"6000",
"6250",
"6500",
"6750",
"7000",
"7250",
"7500",
"7750",
"8000",
"8250",
"8500",
"8750"
//.........这里部分代码省略.........
示例12: KviWindowToolWidget
KviModeEditor::KviModeEditor(QWidget * par, KviWindowToolPageButton * button, const char * name, KviChannelWindow * pChan)
: KviWindowToolWidget(par, button)
{
setObjectName(name);
m_pChannel = pChan;
QGridLayout * pMasterLayout = new QGridLayout(this);
setFocusPolicy(Qt::ClickFocus);
QScrollArea * pScrollArea = new QScrollArea(this);
pScrollArea->viewport()->setBackgroundRole(QPalette::Background);
pMasterLayout->addWidget(pScrollArea, 0, 0);
pMasterLayout->setRowStretch(1, 1);
m_pButton = new QPushButton("", this);
pMasterLayout->addWidget(m_pButton, 1, 0);
connect(m_pButton, SIGNAL(clicked()), this, SLOT(commit()));
if(!m_pChannel || !m_pChannel->connection())
m_pButton->setText(__tr2qs("Close"));
QWidget * pBackground = new QWidget(pScrollArea->viewport());
QGridLayout * g = new QGridLayout(pBackground);
QLabel * l = new QLabel("", pBackground);
l->setPixmap(*(g_pIconManager->getSmallIcon(KviIconManager::Mode)));
g->addWidget(l, 0, 0);
l = new QLabel(__tr2qs("Channel modes"), pBackground);
g->addWidget(l, 0, 1, 1, 1);
QFrame * f = new QFrame(pBackground);
f->setFrameStyle(QFrame::HLine | QFrame::Sunken);
g->addWidget(f, 1, 0, 1, 3);
QCheckBox * pCheckBox = nullptr;
QLineEdit * pLineEdit = nullptr;
int iRow = 1;
QString szTmp;
QString cDesc;
char cMode = 0;
//NOTE: this is a fallback is for some reason we don't have a serverInfo() struct available fot this connection
// The connection is dead and the context was destroyed, don't guess on what was there
if(!m_pChannel || !m_pChannel->connection())
return;
// first, the basic checkable modes pstnmi
QString szModes = "pstnmi";
while(!szModes.isEmpty())
{
cMode = szModes[0].unicode();
szModes.remove(0, 1);
szTmp = QString("%1: %2").arg(cMode).arg(*(getModeDescription(cMode)));
pCheckBox = new QCheckBox(szTmp, pBackground);
m_pCheckBoxes.insert(cMode, pCheckBox);
if(pChan)
pCheckBox->setChecked(pChan->plainChannelMode().contains(cMode));
iRow++;
g->addWidget(pCheckBox, iRow, 0, 1, 3);
}
// second, che basic modes with parameter lk
szModes = "lk";
while(!szModes.isEmpty())
{
cMode = szModes[0].unicode();
szModes.remove(0, 1);
szTmp = QString("%1: %2").arg(cMode).arg(*(getModeDescription(cMode)));
pCheckBox = new QCheckBox(szTmp, pBackground);
m_pCheckBoxes.insert(cMode, pCheckBox);
iRow++;
g->addWidget(pCheckBox, iRow, 0, 1, 3);
connect(pCheckBox, SIGNAL(toggled(bool)), this, SLOT(checkBoxToggled(bool)));
pLineEdit = new QLineEdit(pBackground);
m_pLineEdits.insert(cMode, pLineEdit);
iRow++;
g->addWidget(pLineEdit, iRow, 1, 1, 2);
if(pChan)
{
if(pChan->hasChannelMode(cMode))
{
pCheckBox->setChecked(true);
pLineEdit->setText(pChan->channelModeParam(cMode));
}
else
{
pLineEdit->setEnabled(false);
}
//.........这里部分代码省略.........
示例13: QWidget
PreFlightMiscPage::PreFlightMiscPage(QWidget *parent) :
QWidget(parent)
{
setObjectName("PreFlightMiscPage");
setWindowFlags( Qt::Tool );
setWindowModality( Qt::WindowModal );
setAttribute(Qt::WA_DeleteOnClose);
setWindowTitle( tr("PreFlight - Common") );
if( parent )
{
resize( parent->size() );
}
// Layout used by scroll area
QHBoxLayout *sal = new QHBoxLayout;
// new widget used as container for the dialog layout.
QWidget* sw = new QWidget;
// Scroll area
QScrollArea* sa = new QScrollArea;
sa->setWidgetResizable( true );
sa->setFrameStyle( QFrame::NoFrame );
sa->setWidget( sw );
#ifdef QSCROLLER
QScroller::grabGesture( sa->viewport(), QScroller::LeftMouseButtonGesture );
#endif
#ifdef QTSCROLLER
QtScroller::grabGesture( sa->viewport(), QtScroller::LeftMouseButtonGesture );
#endif
// Add scroll area to its own layout
sal->addWidget( sa );
QHBoxLayout *contentLayout = new QHBoxLayout(this);
// Pass scroll area layout to the content layout.
contentLayout->addLayout( sal, 10 );
// Top layout's parent is the scroll widget
QGridLayout *topLayout = new QGridLayout(sw);
int row = 0;
QLabel *lbl = new QLabel(tr("Minimal arrival altitude:"));
topLayout->addWidget(lbl, row, 0);
// get current set altitude unit. This unit must be considered during
// storage. The internal storage is always in meters.
m_altUnit = Altitude::getUnit();
// Input accept only feet and meters all other make no sense. Therefore all
// other (FL) is treated as feet.
m_edtMinimalArrival = new NumberEditor;
m_edtMinimalArrival->setDecimalVisible( false );
m_edtMinimalArrival->setPmVisible( false );
m_edtMinimalArrival->setRange( 0, 9999);
m_edtMinimalArrival->setMaxLength(4);
m_edtMinimalArrival->setSuffix(" " + Altitude::getUnitText());
QRegExpValidator* eValidator = new QRegExpValidator( QRegExp( "([0-9]{1,4})" ), this );
m_edtMinimalArrival->setValidator( eValidator );
int maw = QFontMetrics(font()).width("9999 ft") + 10;
m_edtMinimalArrival->setMinimumWidth( maw );
topLayout->addWidget(m_edtMinimalArrival, row, 1);
topLayout->setColumnStretch(2, 2);
row++;
lbl = new QLabel(tr("Arrival altitude display:"));
topLayout->addWidget(lbl, row, 0);
m_edtArrivalAltitude = new QComboBox;
m_edtArrivalAltitude->addItem( tr("Landing Target"), GeneralConfig::landingTarget );
m_edtArrivalAltitude->addItem( tr("Next Target"), GeneralConfig::nextTarget );
topLayout->addWidget(m_edtArrivalAltitude, row, 1);
row++;
lbl = new QLabel(tr("QNH:"));
topLayout->addWidget(lbl, row, 0);
m_edtQNH = new NumberEditor;
m_edtQNH->setDecimalVisible( false );
m_edtQNH->setPmVisible( false );
m_edtQNH->setRange( 0, 9999);
m_edtQNH->setMaxLength(4);
m_edtQNH->setSuffix(" hPa");
eValidator = new QRegExpValidator( QRegExp( "([0-9]{1,4})" ), this );
m_edtQNH->setValidator( eValidator );
int mqw = QFontMetrics(font()).width("9999 hPa") + 10;
m_edtQNH->setMinimumWidth( mqw );
topLayout->addWidget(m_edtQNH, row, 1);
row++;
//.........这里部分代码省略.........
示例14: createKMessageBox
int KMessageBox::createKMessageBox(KDialog *dialog, const QIcon &icon,
const QString &text, const QStringList &strlist,
const QString &ask, bool *checkboxReturn, Options options,
const QString &details, QMessageBox::Icon notifyType)
{
QWidget *mainWidget = new QWidget(dialog);
QVBoxLayout *mainLayout = new QVBoxLayout(mainWidget);
mainLayout->setSpacing(KDialog::spacingHint() * 2); // provide extra spacing
mainLayout->setMargin(0);
QHBoxLayout *hLayout = new QHBoxLayout();
hLayout->setMargin(0);
hLayout->setSpacing(-1); // use default spacing
mainLayout->addLayout(hLayout,5);
QLabel *iconLabel = new QLabel(mainWidget);
if (!icon.isNull()) {
QStyleOption option;
option.initFrom(mainWidget);
iconLabel->setPixmap(icon.pixmap(mainWidget->style()->pixelMetric(QStyle::PM_MessageBoxIconSize, &option, mainWidget)));
}
QVBoxLayout *iconLayout = new QVBoxLayout();
iconLayout->addStretch(1);
iconLayout->addWidget(iconLabel);
iconLayout->addStretch(5);
hLayout->addLayout(iconLayout,0);
hLayout->addSpacing(KDialog::spacingHint());
QLabel *messageLabel = new QLabel(text, mainWidget);
messageLabel->setOpenExternalLinks(options & KMessageBox::AllowLink);
Qt::TextInteractionFlags flags = Qt::TextSelectableByMouse | Qt::TextSelectableByKeyboard;
if (options & KMessageBox::AllowLink) {
flags |= Qt::LinksAccessibleByMouse | Qt::LinksAccessibleByKeyboard;
}
messageLabel->setTextInteractionFlags(flags);
QRect desktop = KGlobalSettings::desktopGeometry(dialog);
bool usingSqueezedTextLabel = false;
if (messageLabel->sizeHint().width() > desktop.width() * 0.5) {
// enable automatic wrapping of messages which are longer than 50% of screen width
messageLabel->setWordWrap(true);
// display a text widget with scrollbar if still too wide
usingSqueezedTextLabel = messageLabel->sizeHint().width() > desktop.width() * 0.85;
if (usingSqueezedTextLabel)
{
delete messageLabel;
messageLabel = new KSqueezedTextLabel(text, mainWidget);
messageLabel->setOpenExternalLinks(options & KMessageBox::AllowLink);
messageLabel->setTextInteractionFlags(flags);
}
}
QPalette messagePal(messageLabel->palette());
messagePal.setColor(QPalette::Window, Qt::transparent);
messageLabel->setPalette(messagePal);
bool usingScrollArea=desktop.height() / 3 < messageLabel->sizeHint().height();
if (usingScrollArea)
{
QScrollArea* messageScrollArea = new QScrollArea(mainWidget);
messageScrollArea->setWidget(messageLabel);
messageScrollArea->setFrameShape(QFrame::NoFrame);
messageScrollArea->setWidgetResizable(true);
QPalette scrollPal(messageScrollArea->palette());
scrollPal.setColor(QPalette::Window, Qt::transparent);
messageScrollArea->viewport()->setPalette(scrollPal);
hLayout->addWidget(messageScrollArea,5);
}
else
hLayout->addWidget(messageLabel,5);
const bool usingListWidget=!strlist.isEmpty();
if (usingListWidget) {
// enable automatic wrapping since the listwidget has already a good initial width
messageLabel->setWordWrap(true);
QListWidget *listWidget = new QListWidget(mainWidget);
listWidget->addItems(strlist);
QStyleOptionViewItem styleOption;
styleOption.initFrom(listWidget);
QFontMetrics fm(styleOption.font);
int w = listWidget->width();
Q_FOREACH(const QString &str, strlist) {
w = qMax(w, fm.width(str));
}
const int borderWidth = listWidget->width() - listWidget->viewport()->width() + listWidget->verticalScrollBar()->height();
w += borderWidth;
if (w > desktop.width() * 0.85) { // limit listWidget size to 85% of screen width
w = qRound(desktop.width() * 0.85);
}
listWidget->setMinimumWidth(w);
mainLayout->addWidget(listWidget,usingScrollArea?10:50);
listWidget->setSelectionMode(QListWidget::NoSelection);
messageLabel->setSizePolicy(QSizePolicy::Preferred,QSizePolicy::Minimum);
//.........这里部分代码省略.........
示例15: objectNaming
// we need to make sure the viewport internal widget is named
// qt_scrollarea_viewport, otherwise we're going to confuse Squish
// and friends.
void tst_QAbstractScrollArea::objectNaming()
{
QScrollArea area;
QCOMPARE(area.viewport()->objectName(), QString("qt_scrollarea_viewport"));
}