本文整理汇总了C++中setFocusPolicy函数的典型用法代码示例。如果您正苦于以下问题:C++ setFocusPolicy函数的具体用法?C++ setFocusPolicy怎么用?C++ setFocusPolicy使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了setFocusPolicy函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: QWidget
CKeyReferenceWidget::CKeyReferenceWidget( CSwordBibleModuleInfo *mod, CSwordVerseKey *key, QWidget *parent, const char* /*name*/) :
QWidget(parent),
m_key(key),
m_dropDownHoverTimer(this) {
namespace DU = util::directory;
updatelock = false;
m_module = mod;
setFocusPolicy(Qt::WheelFocus);
QToolButton* clearRef = new QToolButton(this);
clearRef->setIcon(DU::getIcon("edit_clear_locationbar"));
clearRef->setAutoRaise(true);
clearRef->setStyleSheet("QToolButton{margin:0px;}");
connect(clearRef, SIGNAL(clicked()), SLOT(slotClearRef()) );
m_bookScroller = new CScrollerWidgetSet(this);
m_textbox = new BtLineEdit( this );
setFocusProxy(m_textbox);
m_textbox->setContentsMargins(0, 0, 0, 0);
setKey(key); // The order of these two functions is important.
setModule();
m_chapterScroller = new CScrollerWidgetSet(this);
m_verseScroller = new CScrollerWidgetSet(this);
QHBoxLayout* m_mainLayout = new QHBoxLayout( this );
m_mainLayout->setContentsMargins(0, 0, 0, 0);
m_mainLayout->setSpacing(0);
m_mainLayout->addWidget(clearRef);
m_mainLayout->addWidget(m_bookScroller);
m_mainLayout->addWidget(m_textbox);
m_mainLayout->addWidget(m_chapterScroller);
m_mainLayout->addWidget(m_verseScroller);
setTabOrder(m_textbox, 0);
m_dropDownButtons = new QWidget(0);
m_dropDownButtons->setWindowFlags(Qt::Popup);
m_dropDownButtons->setAttribute(Qt::WA_WindowPropagation);
m_dropDownButtons->setCursor(Qt::ArrowCursor);
QHBoxLayout *dropDownButtonsLayout(new QHBoxLayout(m_dropDownButtons));
m_bookDropdownButton = new BtBookDropdownChooserButton(this);
dropDownButtonsLayout->addWidget(m_bookDropdownButton, 2);
m_chapterDropdownButton = new BtChapterDropdownChooserButton(this);
dropDownButtonsLayout->addWidget(m_chapterDropdownButton, 1);
m_verseDropdownButton = new BtVerseDropdownChooserButton(this);
dropDownButtonsLayout->addWidget(m_verseDropdownButton, 1);
dropDownButtonsLayout->setContentsMargins(0, 0, 0, 0);
dropDownButtonsLayout->setSpacing(0);
m_dropDownButtons->setLayout(dropDownButtonsLayout);
m_dropDownButtons->hide();
m_dropDownButtons->installEventFilter(this);
m_dropDownHoverTimer.setInterval(500);
m_dropDownHoverTimer.setSingleShot(true);
connect(&m_dropDownHoverTimer, SIGNAL(timeout()),
m_dropDownButtons, SLOT(hide()));
QString scrollButtonToolTip(tr("Scroll through the entries of the list. Press the button and move the mouse to increase or decrease the item."));
m_bookScroller->setToolTips(
tr("Next book"),
scrollButtonToolTip,
tr("Previous book")
);
m_chapterScroller->setToolTips(
tr("Next chapter"),
scrollButtonToolTip,
tr("Previous chapter")
);
m_verseScroller->setToolTips(
tr("Next verse"),
scrollButtonToolTip,
tr("Previous verse")
);
// signals and slots connections
connect(m_bookScroller, SIGNAL(change(int)), SLOT(slotStepBook(int)));
connect(m_bookScroller, SIGNAL(scroller_pressed()), SLOT(slotUpdateLock()));
connect(m_bookScroller, SIGNAL(scroller_released()), SLOT(slotUpdateUnlock()));
connect(m_textbox, SIGNAL(returnPressed()), SLOT(slotReturnPressed()));
connect(m_chapterScroller, SIGNAL(change(int)), SLOT(slotStepChapter(int)));
connect(m_chapterScroller, SIGNAL(scroller_pressed()), SLOT(slotUpdateLock()));
connect(m_chapterScroller, SIGNAL(scroller_released()), SLOT(slotUpdateUnlock()));
connect(m_verseScroller, SIGNAL(change(int)), SLOT(slotStepVerse(int)));
connect(m_verseScroller, SIGNAL(scroller_pressed()), SLOT(slotUpdateLock()));
connect(m_verseScroller, SIGNAL(scroller_released()), SLOT(slotUpdateUnlock()));
}
示例2: QWidget
SpikePlot_CV::SpikePlot_CV(SignalProcessor *inSignalProcessor, SignalChannel *initialChannel,
ConductionVelocityDialog *inConductionVelocityDialog, QWidget *parent) :
QWidget(parent)
{
signalProcessor = inSignalProcessor;
conductionVelocityDialog = inConductionVelocityDialog;
selectedChannel = initialChannel;
startingNewChannel = true;
rmsDisplayPeriod = 0;
savedRms = 0.0;
spikeWaveformIndex = 0;
numSpikeWaveforms = 0;
maxNumSpikeWaveforms = 20;
voltageTriggerMode = true;
voltageThreshold = 0;
digitalTriggerChannel = 0;
digitalEdgePolarity = true;
setBackgroundRole(QPalette::Window);
setAutoFillBackground(true);
setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred);
setFocusPolicy(Qt::StrongFocus);
int i;
// We can plot up to 30 superimposed spike waveforms on the scope.
spikeWaveform.resize(30);
for (i = 0; i < spikeWaveform.size(); ++i) {
// Each waveform is 3 ms in duration. We need 91 time steps for a 3 ms
// waveform with the sample rate is set to its maximum value of 30 kS/s.
spikeWaveform[i].resize(91);
spikeWaveform[i].fill(0.0);
}
// Buffers to hold recent history of spike waveform and digital input,
// used to find trigger events.
spikeWaveformBuffer.resize(10000);
spikeWaveformBuffer.fill(0.0);
digitalInputBuffer.resize(10000);
digitalInputBuffer.fill(0);
// Set up vectors of varying plot colors so that older waveforms
// are plotted in low-contrast gray and new waveforms are plotted
// in high-contrast blue. Older signals fade away, like phosphor
// traces on old-school CRT oscilloscopes.
scopeColors.resize(3);
scopeColors[0].resize(10);
scopeColors[1].resize(20);
scopeColors[2].resize(30);
for (i = 6; i < 10; ++i) scopeColors[0][i] = Qt::blue;
for (i = 3; i < 6; ++i) scopeColors[0][i] = Qt::darkGray;
for (i = 0; i < 3; ++i) scopeColors[0][i] = Qt::lightGray;
for (i = 12; i < 20; ++i) scopeColors[1][i] = Qt::blue;
for (i = 6; i < 12; ++i) scopeColors[1][i] = Qt::darkGray;
for (i = 0; i < 6; ++i) scopeColors[1][i] = Qt::lightGray;
for (i = 18; i < 30; ++i) scopeColors[2][i] = Qt::blue;
for (i = 9; i < 18; ++i) scopeColors[2][i] = Qt::darkGray;
for (i = 0; i < 9; ++i) scopeColors[2][i] = Qt::lightGray;
// Default values that may be overwritten.
yScale = 5000;
setSampleRate(30000.0);
}
示例3: QDialog
setColValuesDialog::setColValuesDialog( ScriptingEnv *env, QWidget* parent, const char* name, bool modal, WFlags fl )
: QDialog( parent, name, modal, fl )
{
scriptEnv = env;
if ( !name )
setName( "setColValuesDialog" );
setCaption( tr( "QtiPlot - Set column values" ) );
setFocusPolicy( QDialog::StrongFocus );
QHBox *hbox1=new QHBox (this, "hbox1");
hbox1->setSpacing (5);
QVBox *box1=new QVBox (hbox1, "box2");
box1->setSpacing (5);
explain = new QTextEdit(box1, "explain" );
explain->setReadOnly (true);
explain->setPaletteBackgroundColor(QColor(197, 197, 197));
colNameLabel = new QLabel(box1, "colNameLabel" );
QVBox *box2=new QVBox (hbox1, "box2");
box2->setMargin(5);
box2->setFrameStyle (QFrame::Box);
QHBox *hbox2=new QHBox (box2, "hbox2");
hbox2->setMargin(5);
hbox2->setSpacing (5);
QLabel *TextLabel1 = new QLabel(hbox2, "TextLabel1" );
TextLabel1->setText( tr( "For row (i)" ) );
start = new QSpinBox(hbox2, "start" );
QLabel *TextLabel2 = new QLabel(hbox2, "TextLabel2" );
TextLabel2->setText( tr( "to" ) );
end = new QSpinBox(hbox2, "end" );
start->setMinValue(1);
end->setMinValue(1);
if (sizeof(int)==2)
{ // 16 bit signed integer
start->setMaxValue(0x7fff);
end->setMaxValue(0x7fff);
}
else
{ // 32 bit signed integer
start->setMaxValue(0x7fffffff);
end->setMaxValue(0x7fffffff);
}
QButtonGroup *GroupBox0 = new QButtonGroup(2,QGroupBox::Horizontal,tr( "" ),box2, "GroupBox0" );
GroupBox0->setLineWidth(0);
GroupBox0->setFlat(true);
functions = new QComboBox( FALSE, GroupBox0, "functions" );
PushButton3 = new QPushButton(GroupBox0, "PushButton3" );
PushButton3->setText( tr( "Add function" ) );
boxColumn = new QComboBox( FALSE, GroupBox0, "boxColumn" );
PushButton4 = new QPushButton(GroupBox0, "PushButton4" );
PushButton4->setText( tr( "Add column" ) );
QHBox *hbox6=new QHBox (GroupBox0, "hbox6");
hbox6->setSpacing (5);
buttonPrev = new QPushButton( hbox6, "buttonPrev" );
buttonPrev->setText("&<<");
buttonNext = new QPushButton( hbox6, "buttonNext" );
buttonNext->setText("&>>");
addCellButton = new QPushButton(GroupBox0, "addCellButton" );
addCellButton->setText( tr( "Add cell" ) );
QHBox *hbox3=new QHBox (this, "hbox3");
hbox3->setSpacing (5);
commandes = new ScriptEdit( env, hbox3, "commandes" );
commandes->setGeometry( QRect(10, 100, 260, 70) );
commandes->setFocus();
QVBox *box3=new QVBox (hbox3,"box3");
box3->setSpacing (5);
btnOk = new QPushButton(box3, "btnOk" );
btnOk->setText( tr( "OK" ) );
btnApply = new QPushButton(box3, "btnApply" );
btnApply->setText( tr( "Apply" ) );
btnCancel = new QPushButton( box3, "btnCancel" );
btnCancel->setText( tr( "Cancel" ) );
QVBoxLayout* layout = new QVBoxLayout(this,5,5, "hlayout3");
layout->addWidget(hbox1);
layout->addWidget(hbox3);
//.........这里部分代码省略.........
示例4: QGLWidget
GLView::GLView( const QGLFormat & format, QWidget * p, const QGLWidget * shareWidget )
: QGLWidget( format, p, shareWidget )
{
setFocusPolicy( Qt::ClickFocus );
//setAttribute( Qt::WA_PaintOnScreen );
//setAttribute( Qt::WA_NoSystemBackground );
setAutoFillBackground( false );
setAcceptDrops( true );
setContextMenuPolicy( Qt::CustomContextMenu );
// Manually handle the buffer swap
// Fixes bug with QGraphicsView and double buffering
// Input becomes sluggish and CPU usage doubles when putting GLView
// inside a QGraphicsView.
setAutoBufferSwap( false );
// Make the context current on this window
makeCurrent();
// Create an OpenGL context
glContext = context()->contextHandle();
// Obtain a functions object and resolve all entry points
glFuncs = glContext->functions();
if ( !glFuncs ) {
Message::critical( this, tr( "Could not obtain OpenGL functions" ) );
exit( 1 );
}
glFuncs->initializeOpenGLFunctions();
view = ViewDefault;
animState = AnimEnabled;
debugMode = DbgNone;
Zoom = 1.0;
doCenter = false;
doCompile = false;
model = nullptr;
time = 0.0;
lastTime = QTime::currentTime();
textures = new TexCache( this );
scene = new Scene( textures, glContext, glFuncs );
connect( textures, &TexCache::sigRefresh, this, static_cast<void (GLView::*)()>(&GLView::update) );
connect( scene, &Scene::sceneUpdated, this, static_cast<void (GLView::*)()>(&GLView::update) );
timer = new QTimer( this );
timer->setInterval( 1000 / FPS );
timer->start();
connect( timer, &QTimer::timeout, this, &GLView::advanceGears );
lightVisTimeout = 1500;
lightVisTimer = new QTimer( this );
lightVisTimer->setSingleShot( true );
connect( lightVisTimer, &QTimer::timeout, [this]() { setVisMode( Scene::VisLightPos, false ); update(); } );
connect( Options::get(), &Options::sigFlush3D, textures, &TexCache::flush );
connect( Options::get(), &Options::sigChanged, this, static_cast<void (GLView::*)()>(&GLView::update) );
connect( Options::get(), &Options::materialOverridesChanged, this, &GLView::updateScene );
}
示例5: QGLWidget
VisorOpenGL::VisorOpenGL(QWidget *parent)
: QGLWidget(parent) {
// Definimos el tamaño del volumen de visualización
Window_width=5;//5;
Window_height=5;//5;
Front_plane=10;
Back_plane=1000;
// permitimos al componente tener el foco y aceptar eventos
setFocusPolicy(Qt::StrongFocus);
//iniciamos las camaras
Camera camera;
//camara 1 frente
this->VRP.x=250;this->VRP.y=200;this->VRP.z=0;
this->VPN.x=1;this->VPN.y=1;this->VPN.z=0;
this->VUP.x=0;this->VUP.y=1;this->VUP.z=0;
camera.set(VRP,VPN,VUP);
cameras.push_back(camera);
//camara 2
this->VRP.x=100;this->VRP.y=75;this->VRP.z=200;
this->VPN.x=1;this->VPN.y=1;this->VPN.z=3;
this->VUP.x=0;this->VUP.y=1;this->VUP.z=0;
camera.set(VRP,VPN,VUP);
camera.fixedCamera(true);
cameras.push_back(camera);
//camara 3 vista pajaro
this->VRP.x=0;this->VRP.y=300;this->VRP.z=0;
this->VPN.x=0;this->VPN.y=1;this->VPN.z=0;
this->VUP.x=1;this->VUP.y=0;this->VUP.z=0;
camera.set(VRP,VPN,VUP);
cameras.push_back(camera);
//camara 4 lateral drcho
this->VRP.x=0;this->VRP.y=40;this->VRP.z=-200;
this->VPN.x=0;this->VPN.y=0;this->VPN.z=-1;
this->VUP.x=0;this->VUP.y=1;this->VUP.z=0;
camera.set(VRP,VPN,VUP);
cameras.push_back(camera);
//camara 5 cam ajustable
this->VRP.x=0;this->VRP.y=40;this->VRP.z=0;
this->VPN.x=1;this->VPN.y=1;this->VPN.z=0;
this->VUP.x=0;this->VUP.y=-1;this->VUP.z=0;
camera.set(VRP,VPN,VUP);
cameras.push_back(camera);
//camara 6 gallery cam
this->VRP.x=15;this->VRP.y=10;this->VRP.z=0;
this->VPN.x=1;this->VPN.y=1;this->VPN.z=0;
this->VUP.x=0;this->VUP.y=1;this->VUP.z=0;
camera.set(VRP,VPN,VUP);
cameras.push_back(camera);
//definimos la camara a visualizar
camera_actual = 0;
ncameras = 5 ;
_fog = false;
}
示例6: QDialog
//.........这里部分代码省略.........
backgroundBox->insertItem( tr( "Shadow" ) );
}
buttonCancel = new QPushButton( GroupBox1, "buttonCancel" );
buttonCancel->setText( tr( "&Cancel" ) );
if (text_type == TextMarker)
{
new QLabel(tr("Background"), GroupBox1, "TextLabel2",0 );
backgroundBtn = new ColorButton(GroupBox1);
connect(backgroundBtn, SIGNAL(clicked()), this, SLOT(pickBackgroundColor()));
buttonDefault = new QPushButton( GroupBox1);
buttonDefault->setText( tr( "Set &Default" ) );
connect(buttonDefault, SIGNAL(clicked()), this, SLOT(setDefaultValues()));
}
QLabel* rotate=new QLabel(tr( "Rotate (deg.)" ),GroupBox1, "TextLabel1_2",0);
rotate->hide();
rotateBox = new QComboBox( FALSE, GroupBox1, "rotateBox" );
rotateBox->insertItem( tr( "0" ) );
rotateBox->insertItem( tr( "45" ) );
rotateBox->insertItem( tr( "90" ) );
rotateBox->insertItem( tr( "135" ) );
rotateBox->insertItem( tr( "180" ) );
rotateBox->insertItem( tr( "225" ) );
rotateBox->insertItem( tr( "270" ) );
rotateBox->insertItem( tr( "315" ) );
rotateBox->setEditable (TRUE);
rotateBox->setCurrentItem(0);
rotateBox->hide();
GroupBox2= new QButtonGroup(8, QGroupBox::Horizontal, QString::null,this, "GroupBox2" );
if (text_type == TextMarker)
{
buttonCurve = new QPushButton( GroupBox2, "buttonCurve" );
buttonCurve->setPixmap (QPixmap(lineSymbol_xpm));
connect( buttonCurve, SIGNAL( clicked() ), this, SLOT(addCurve() ) );
}
buttonIndice = new QPushButton( GroupBox2, "buttonIndice" );
buttonIndice->setPixmap (QPixmap(index_xpm));
buttonExp = new QPushButton( GroupBox2, "buttonExp" );
buttonExp->setPixmap (QPixmap(exp_xpm));
buttonMinGreek = new QPushButton(QChar(0x3B1), GroupBox2, "buttonMinGreek" );
buttonMinGreek->setMaximumWidth(40);
buttonMajGreek = new QPushButton(QChar(0x393), GroupBox2, "buttonMajGreek" );
buttonMajGreek->setMaximumWidth(40);
QFont font = this->font();
font.setBold(true);
buttonB = new QPushButton(tr("B"), GroupBox2, "buttonB" );
buttonB->setFont(font);
buttonB->setMaximumWidth(40);
font = this->font();
font.setItalic(true);
buttonI = new QPushButton(tr("It"), GroupBox2, "buttonI" );
buttonI->setFont(font);
buttonI->setMaximumWidth(40);
font = this->font();
font.setUnderline(true);
buttonU = new QPushButton(tr("U"), GroupBox2, "buttonU" );
buttonU->setFont(font);
buttonU->setMaximumWidth(40);
textEditBox = new QTextEdit( this);
textEditBox->setTextFormat(QTextEdit::PlainText);
setFocusPolicy(QWidget::StrongFocus);
setFocusProxy(textEditBox);
QVBoxLayout* vlayout = new QVBoxLayout(this,5,5, "vlayout");
vlayout->addWidget(GroupBox1);
vlayout->addWidget(GroupBox2);
vlayout->addWidget(textEditBox);
// signals and slots connections
connect( colorBox, SIGNAL( clicked() ), this, SLOT( pickTextColor() ) );
connect( buttonOk, SIGNAL( clicked() ), this, SLOT( accept() ) );
connect( buttonApply, SIGNAL( clicked() ), this, SLOT( apply() ) );
connect( buttonCancel, SIGNAL( clicked() ), this, SLOT( reject() ) );
connect( buttonFont, SIGNAL( clicked() ), this, SLOT(customFont() ) );
connect( buttonExp, SIGNAL( clicked() ), this, SLOT(addExp() ) );
connect( buttonIndice, SIGNAL( clicked() ), this, SLOT(addIndex() ) );
connect( buttonU, SIGNAL( clicked() ), this, SLOT(addUnderline() ) );
connect( buttonI, SIGNAL( clicked() ), this, SLOT(addItalic() ) );
connect( buttonB, SIGNAL( clicked() ), this, SLOT(addBold() ) );
connect( buttonMinGreek, SIGNAL(clicked()), this, SLOT(showMinGreek()));
connect( buttonMajGreek, SIGNAL(clicked()), this, SLOT(showMajGreek()));
}
示例7: QWidget
AnimationForm::AnimationForm(CEditData *pImageData, CSettings *pSetting, QWidget *parent) :
QWidget(parent),
ui(new Ui::AnimationForm)
{
m_pEditData = pImageData ;
m_pSetting = pSetting ;
m_bDontSetData = false ;
m_frameStart = pSetting->getFrameStart() ;
m_frameEnd = pSetting->getFrameEnd() ;
m_oldWinSize = QSize(-1, -1) ;
ui->setupUi(this);
m_pEditData->setTreeView(ui->treeView) ;
ui->label_frame->setEditData(m_pEditData) ;
ui->label_frame->setHorizontalBar(ui->horizontalScrollBar_frame) ;
m_pDataMarker = ui->label_frame ;
setFocusPolicy(Qt::StrongFocus);
m_pGlWidget = new AnimeGLWidget(pImageData, pSetting, this) ;
ui->scrollArea_anime->setWidget(m_pGlWidget);
m_pGlWidget->resize(m_pSetting->getAnmWindowW(), m_pSetting->getAnmWindowH());
m_pGlWidget->setDrawArea(m_pSetting->getAnmWindowW(), m_pSetting->getAnmWindowH());
m_pGlWidget->show();
ui->radioButton_pos->setChecked(true);
ui->checkBox_grid->setChecked(true);
ui->spinBox_fps->setValue(60) ;
ui->checkBox_frame->setChecked(pSetting->getDrawFrame());
ui->checkBox_center->setChecked(pSetting->getDrawCenter());
ui->spinBox_frame_start->setValue(m_frameStart) ;
ui->spinBox_frame_end->setValue(m_frameEnd) ;
ui->label_frame->slot_setFrameStart(m_frameStart) ;
ui->label_frame->slot_setFrameEnd(m_frameEnd) ;
for ( int i = 0 ; i < m_pEditData->getImageDataListSize() ; i ++ ) {
CEditData::ImageData *p = m_pEditData->getImageData(i) ;
if ( !p ) { continue ; }
ui->comboBox_image_no->addItem(tr("%1").arg(p->nNo));
}
m_pSplitter = new AnimationWindowSplitter(this) ;
m_pSplitter->addWidget(ui->treeView) ;
m_pSplitter->addWidget(ui->scrollArea_anime) ;
m_pSplitter->setGeometry(ui->treeView->pos().x(),
ui->treeView->pos().y(),
ui->scrollArea_anime->width()+ui->scrollArea_anime->pos().x()-ui->treeView->pos().x(),
ui->treeView->height());
{
CObjectModel *pModel = m_pEditData->getObjectModel() ;
ui->treeView->setModel(pModel);
ui->treeView->header()->setHidden(true);
ui->treeView->setContextMenuPolicy(Qt::CustomContextMenu);
ui->treeView->setDragEnabled(true) ;
ui->treeView->setAcceptDrops(true) ;
ui->treeView->setDropIndicatorShown(true) ;
ui->treeView->setDragDropMode(QAbstractItemView::DragDrop) ;
ui->treeView->setFocusPolicy(Qt::NoFocus);
ObjectItem *root = pModel->getItemFromIndex(QModelIndex()) ;
if ( !root->childCount() ) {
addNewObject(trUtf8("New Object"));
}
else {
if ( root->child(0) ) {
QModelIndex index = pModel->index(0) ;
ui->treeView->setCurrentIndex(index);
}
}
}
m_pActTreeViewAdd = new QAction(QString("Add Object"), this);
m_pActTreeViewCopy = new QAction(QString("Copy Object"), this) ;
m_pActTreeViewDel = new QAction(QString("Delete"), this);
m_pActTreeViewLayerDisp = new QAction(QString("Disp"), this) ;
m_pActTreeViewLayerLock = new QAction(QString("Lock"), this) ;
m_pTimer = new QTimer(this) ;
m_pTimer->setInterval((int)(100.0f/6.0f));
connect(ui->label_frame, SIGNAL(sig_changeValue(int)), this, SLOT(slot_frameChanged(int))) ;
connect(ui->radioButton_pos, SIGNAL(clicked(bool)), this, SLOT(slot_clickedRadioPos(bool))) ;
connect(ui->radioButton_rot, SIGNAL(clicked(bool)), this, SLOT(slot_clickedRadioRot(bool))) ;
connect(ui->radioButton_center, SIGNAL(clicked(bool)), this, SLOT(slot_clickedRadioCenter(bool))) ;
connect(ui->radioButton_scale, SIGNAL(clicked(bool)), this, SLOT(slot_clickedRadioScale(bool))) ;
connect(ui->radioButton_path, SIGNAL(clicked(bool)), this, SLOT(slot_clickedRadioPath(bool))) ;
connect(ui->treeView, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(slot_treeViewMenuReq(QPoint))) ;
connect(ui->treeView, SIGNAL(clicked(QModelIndex)), this, SLOT(slot_changeSelectObject(QModelIndex))) ;
connect(m_pGlWidget, SIGNAL(sig_dropedImage(QRectF, QPoint, int)), this, SLOT(slot_dropedImage(QRectF, QPoint, int))) ;
connect(m_pGlWidget, SIGNAL(sig_selectLayerChanged(QModelIndex)), this, SLOT(slot_selectLayerChanged(QModelIndex))) ;
connect(m_pGlWidget, SIGNAL(sig_dragedImage(FrameData)), this, SLOT(slot_setUI(FrameData))) ;
connect(m_pGlWidget, SIGNAL(sig_deleteFrameData()), this, SLOT(slot_deleteFrameData())) ;
//.........这里部分代码省略.........
示例8: setFocusProxy
void DateFormWidget::setupFocusPolicy()
{
m_dateTimeEdit->setFocusPolicy(Qt::ClickFocus);
setFocusProxy(m_dateTimeEdit);
setFocusPolicy(Qt::StrongFocus);
}
示例9: QwtPlot
Plot::Plot(int width, int height, QWidget *parent, const char *)
: QwtPlot(parent)
{
setAutoReplot (false);
marker_key = 0;
curve_key = 0;
minTickLength = 5;
majTickLength = 9;
setGeometry(QRect(0, 0, width, height));
setAxisTitle(QwtPlot::yLeft, tr("Y Axis Title"));
setAxisTitle(QwtPlot::xBottom, tr("X Axis Title"));
//due to the plot layout updates, we must always have a non empty title
setAxisTitle(QwtPlot::yRight, tr(" "));
setAxisTitle(QwtPlot::xTop, tr(" "));
// grid
d_grid = new Grid();
d_grid->attach(this);
//custom scale
for (int i= 0; i<QwtPlot::axisCnt; i++) {
QwtScaleWidget *scale = (QwtScaleWidget *) axisWidget(i);
if (scale) {
scale->setMargin(0);
//the axis title color must be initialized...
QwtText title = scale->title();
title.setColor(Qt::black);
scale->setTitle(title);
//...same for axis color
QPalette pal = scale->palette();
pal.setColor(QPalette::Foreground, QColor(Qt::black));
scale->setPalette(pal);
ScaleDraw *sd = new ScaleDraw(this);
sd->setTickLength(QwtScaleDiv::MinorTick, minTickLength);
sd->setTickLength(QwtScaleDiv::MediumTick, minTickLength);
sd->setTickLength(QwtScaleDiv::MajorTick, majTickLength);
setAxisScaleDraw (i, sd);
setAxisScaleEngine (i, new ScaleEngine());
}
}
QwtPlotLayout *pLayout = plotLayout();
pLayout->setCanvasMargin(0);
pLayout->setAlignCanvasToScales (true);
QwtPlotCanvas* plCanvas = canvas();
plCanvas->setFocusPolicy(Qt::StrongFocus);
plCanvas->setFocusIndicator(QwtPlotCanvas::ItemFocusIndicator);
//plCanvas->setFocus();
plCanvas->setFrameShadow(QwtPlot::Plain);
plCanvas->setCursor(Qt::arrowCursor);
plCanvas->setLineWidth(0);
plCanvas->setPaintAttribute(QwtPlotCanvas::PaintCached, false);
plCanvas->setPaintAttribute(QwtPlotCanvas::PaintPacked, false);
QColor background = QColor(Qt::white);
background.setAlpha(255);
QPalette palette;
palette.setColor(QPalette::Window, background);
setPalette(palette);
setCanvasBackground (background);
setFocusPolicy(Qt::StrongFocus);
//setFocusProxy(plCanvas);
setFrameShape(QFrame::Box);
setLineWidth(0);
}
示例10: QWidget
FxWidget::FxWidget(QWidget *parent, Qt::WindowFlags flag) :
QWidget(parent, flag)
{
FX_FUNCTION
bgScaleLeft = 65;
bgScaleRight = 130;
bgScaleBottom = 58;
bgScaleTop = 135;
_autoHide = false;
_enableautoHide = false;
_isSetSystemTitleBar = false;
// for "editable label"
setFocusPolicy(Qt::ClickFocus);
//resizer
QWidgetResizeHandler *qwrh = new QWidgetResizeHandler(this);
Q_UNUSED(qwrh);
/*
_______________________________________________________
| _____________________________________________ | ___ |
| | titleBar | | |s| |
| | icon | title | min | max | close | | | |i| |
| |___________________________________________| | |d| |
| ____________________________________________ | |e| |
| | | | |B| |
| | | | |a| |
| | contentWidget | | |r| |
| | | | |R| |
| | | | |L| |
| |___________________________________________| | |_| |
|_______________________________________________|_____|
| ___________________________________________ | |
| |______________sideBarTB___________________| | |
|_______________________________________________|_____|
*/
_mainLayout = new QGridLayout(this);
contentWidget = new QWidget(this);
titleBar = new FxWidgetTitleBar(this);
connect(this, SIGNAL(triggleMaximizeAndNormal()), titleBar->btnMaximize,
SLOT(click()));
_mainLayout->addWidget(titleBar, 0, 0);
_mainLayout->addWidget(contentWidget, 1, 0);
sideBarRL = new QLabel(this);
sideBarRL->setSizePolicy(QSizePolicy(QSizePolicy::Ignored,
QSizePolicy::Expanding));
sideBarRL->setMaximumWidth(3); //@To FIX magic number
sideBarTB = new QLabel(this);
sideBarTB->setSizePolicy(QSizePolicy(QSizePolicy::Expanding,
QSizePolicy::Ignored));
//sideBarRL->setMaximumHeight(3);//@To FIX magic number
sideBarTB->setObjectName("sideBarTB");
sideBarRL->setObjectName("sideBarRL");
_mainLayout->addWidget(sideBarRL, 0, 0, 2, 1);
_mainLayout->addWidget(sideBarTB, 2, 0);
sideBarRL->hide();
sideBarTB->hide();
_mainLayout->setSpacing(0);
_mainLayout->setMargin(0);
setContentsMargins(3, 0, 3, 3);
QWidget::setLayout(_mainLayout);
orientSize = size();
updateWindowPositionType();
}
示例11: QGraphicsScene
MainWindow::MainWindow(QApplication* a_) {
a=a_;
score=0, lives=5;
interval=0;
paused=false;
//Initialize unused pointers
timer = NULL;
player = NULL;
pauseButton = NULL;
resignButton = NULL;
quitButton = NULL;
//We need a scene and a view to do graphics in QT
scene = new QGraphicsScene();
setScene(scene);
//This sets the size of the window and gives it a title.
setFixedSize( 1005, 505 );
setWindowTitle( "Caterpillars");
setFocusPolicy(Qt::StrongFocus);
setFocus();
mainMap = new QPixmap("images/main.png");
canvas = new Canvas(0, 0, 1000, 500, 20, 0, 0, 0);
canvas->setPixmap(*mainMap);
scene->addItem(canvas);
titleText = new QGraphicsSimpleTextItem("THE VERY HUNGRY\n CATERPILLAR");
titleText->setPos(220,100);
titleText->setFont(QFont("Times New Roman", 40, QFont::Bold));
titleText->setPen(QPen(Qt::white, 1, Qt::SolidLine));
scene->addItem(titleText);
subtitleText = new QGraphicsSimpleTextItem("A Qt game by Eric Pakravan, based on the story and artwork by Eric Carle");
subtitleText->setPos(160,252);
subtitleText->setFont(QFont("Ubuntu", 14, QFont::Bold));
scene->addItem(subtitleText);
scoreCaptionText = new QGraphicsSimpleTextItem("Score: ");
scoreCaptionText->setPos(500,2);
scoreCaptionText->setFont(QFont("Ubuntu", 15, QFont::Bold));
scoreCaptionText->setPen(QPen(Qt::red, 1, Qt::SolidLine));
livesCaptionText = new QGraphicsSimpleTextItem("Lives: ");
livesCaptionText->setPos(750,2);
livesCaptionText->setFont(QFont("Ubuntu", 15, QFont::Bold));
livesCaptionText->setPen(QPen(Qt::red, 1, Qt::SolidLine));
scoreText = new QGraphicsSimpleTextItem(QString::number(score));
scoreText->setPos(565,2);
scoreText->setFont(QFont("Ubuntu", 15, QFont::Bold));
scoreText->setPen(QPen(Qt::red, 1, Qt::SolidLine));
livesText = new QGraphicsSimpleTextItem(QString::number(lives));
livesText->setPos(810,2);
livesText->setFont(QFont("Ubuntu", 15, QFont::Bold));
livesText->setPen(QPen(Qt::red, 1, Qt::SolidLine));
startButton = new QPushButton("Start!", this);
startButton->setMinimumWidth(120);
startButton->move(440, 280);
startButton->setFont(QFont("Ubuntu", 20, QFont::Bold));
connect(startButton, SIGNAL(clicked()), this, SLOT(StartGame()));
startButton->show();
backgroundMap = new QPixmap("images/background.png");
caterpillarMap = new QPixmap("images/caterpillar.png");
leafMap = new QPixmap("images/leaf.png");
strawberryMap = new QPixmap("images/strawberry.png");
orangeMap = new QPixmap("images/orange.png");
plumMap = new QPixmap("images/plum.png");
appleMap = new QPixmap("images/apple.png");
pearMap = new QPixmap("images/pear.png");
sunMap = new QPixmap("images/sun.png");
ladybugMap = new QPixmap("images/ladybug.png");
spiderMap = new QPixmap("images/spider.png");
beeMap = new QPixmap("images/bee.png");
cakeMap = new QPixmap("images/cake.png");
pieMap = new QPixmap("images/pie.png");
icecreamMap = new QPixmap("images/icecream.png");
cupcakeMap = new QPixmap("images/cupcake.png");
}
示例12: OptionForm
/*
* Constructs a OptionDlg which is a child of 'parent', with the
* name 'name' and widget flags set to 'f'
*/
OptionDlg::OptionDlg( QWidget* parent, const char* name, WFlags fl )
: OptionForm( parent, name, fl )
{
connect(m_btnOK, SIGNAL(clicked()), this, SLOT(updateSettings()));
connect(m_btnCancel, SIGNAL(clicked()), this, SIGNAL(endDialog()));
// font option ( check OptionDlg::updateExFont method );
m_wFonts->insertItem(tr("Default Font"), 0);
//m_wFonts->insertItem("Progress Bar", 1);
// color option ( check OptionDlg::updateExColor method )
m_wColors->insertItem(tr("Background"), 0);
m_wColors->insertItem(tr("Normal Text"), 1);
m_wColors->insertItem(tr("HighLight Text 1"), 2);
m_wColors->insertItem(tr("HighLight Text 2"), 3);
m_wColors->insertItem(tr("HighLight Text 3"), 4);
m_wColors->insertItem(tr("HighLight Text 4"), 5);
m_wColors->insertItem(tr("HighLight Text 5"), 6);
m_wColors->insertItem(tr("HighLight Text 6"), 7);
m_wColors->insertItem(tr("HighLight Text 7"), 8);
m_wColors->insertItem(tr("Progress Bar FG"), 9);
m_wColors->insertItem(tr("Progress Bar BG"), 10);
m_wColors->insertItem(tr("Progress Bar Text"), 11);
m_wFontName->insertStringList(QFontDatabase().families());
connect(m_wFontName, SIGNAL(activated(int)), this, SLOT(updateFontFace()));
connect(m_wFontSize, SIGNAL(valueChanged(int)), this, SLOT(updateFontFace()));
connect(m_wFonts, SIGNAL(activated(int)), this, SLOT(changeFont()));
connect(m_wBold, SIGNAL(toggled(bool)), this, SLOT(updateFontFace()));
connect(m_wFakeBold, SIGNAL(toggled(bool)), this, SLOT(updateFontFace()));
connect(m_wColors, SIGNAL(activated(int)), this, SLOT(changeColor()));
connect(m_wColorEdit, SIGNAL(returnPressed()), this, SLOT(updateColorFace()));
connect(m_wRed, SIGNAL(valueChanged(int)), this, SLOT(rgbChange()));
connect(m_wGreen, SIGNAL(valueChanged(int)), this, SLOT(rgbChange()));
connect(m_wBlue, SIGNAL(valueChanged(int)), this, SLOT(rgbChange()));
connect(m_wMargin, SIGNAL(valueChanged(int)), this, SLOT(updateMargin(int)));
connect(m_wLineMargin, SIGNAL(valueChanged(int)),
this, SLOT(updateLineMargin(int)));
connect(m_wRotation, SIGNAL(valueChanged(int)),
this, SLOT(updateRotation(int)));
connect(m_wShowBar, SIGNAL(toggled(bool)),
this, SLOT(updateBar()));
connect(m_wBarHeight, SIGNAL(valueChanged(int)),
this, SLOT(updateBar()));
connect(m_wScrollHeight, SIGNAL(valueChanged(int)),
this, SLOT(updateScrollHeight(int)));
connect(m_wScrollDelay, SIGNAL(valueChanged(int)),
this, SLOT(updateScrollDelay(int)));
connect(m_wScalingMethod,SIGNAL(activated(int)),
this, SLOT(updateScaleMethod(int)));
connect(m_wScaleFactor,SIGNAL(valueChanged(int)),
this, SLOT(updateScaleFactor(int)));
connect(m_wScaleUp,SIGNAL(stateChanged(int)),
this, SLOT(updateScaleUp(int)));
connect(m_wHSlices,SIGNAL(valueChanged(int)),
this, SLOT(updateSlicingCount()));
connect(m_wVSlices,SIGNAL(valueChanged(int)),
this, SLOT(updateSlicingCount()));
connect(m_wScrollMethod,SIGNAL(activated(int)),
this, SLOT(updateScrollPolicy(int)));
connect(m_wPageMethod, SIGNAL(activated(int)),
this, SLOT(updatePagingPolicy(int)));
setFocusPolicy(QWidget::StrongFocus);
m_cfg = NULL;
}
示例13: FlexButton
FlexButton(QWidget* parent, Flex::Button button) : QToolButton(parent), _button(button)
{
setFixedSize(16, 16); setFocusPolicy(Qt::NoFocus);
}
示例14: QAbstractItemView
KNMusicAlbumView::KNMusicAlbumView(QWidget *parent) :
QAbstractItemView(parent),
m_shadowSource(QPixmap("://public/shadow.png")),
m_albumArtShadow(QPixmap()),
m_albumBase(QPixmap(":/plugin/music/public/base.png")),
m_scaledAlbumBase(QPixmap()),
m_noAlbumArt(knMusicGlobal->noAlbumArt()),
m_scaledNoAlbumArt(QPixmap()),
m_nullIndex(QModelIndex()),
m_selectedIndex(m_nullIndex),
m_mouseDownIndex(m_nullIndex),
m_scrollAnime(new QTimeLine(200, this)),
m_proxyModel(nullptr),
m_model(nullptr),
m_albumDetail(nullptr),
m_itemWidth(135),
m_itemMinimalSpacing(30),
m_minimalWidth(m_itemMinimalSpacing+m_itemWidth),
m_lineCount(0),
m_textSpacing(5),
m_itemHeight(154),
m_spacing(30),
m_itemSpacingHeight(m_spacing+m_itemHeight),
m_itemSpacingWidth(m_spacing+m_itemWidth),
m_maxColumnCount(0)
{
setObjectName("MusicAlbumView");
//Set properties.
setFocusPolicy(Qt::WheelFocus);
//Set default scrollbar properties.
verticalScrollBar()->setRange(0, 0);
//Set the palette.
knTheme->registerWidget(this);
//Configure the timeline.
m_scrollAnime->setUpdateInterval(10);
m_scrollAnime->setEasingCurve(QEasingCurve::OutCubic);
connect(m_scrollAnime, &QTimeLine::frameChanged,
verticalScrollBar(), &QScrollBar::setValue);
//Link the scrolling event.
connect(verticalScrollBar(), &QScrollBar::valueChanged,
this, &KNMusicAlbumView::onActionScrolling);
//The icon size should be the item width.
//Update the painting parameters.
updateUIElements();
//Generate the album art shadow pixmap.
int shadowSize=m_itemWidth+(m_shadowIncrease<<1);
//Update album art shadow.
m_albumArtShadow=generateShadow(shadowSize, shadowSize);
//Update the album base.
m_scaledAlbumBase=m_albumBase.scaled(m_itemWidth,
m_itemWidth,
Qt::IgnoreAspectRatio,
Qt::SmoothTransformation);
//Update the no album art.
m_scaledNoAlbumArt=m_noAlbumArt.scaled(m_itemWidth,
m_itemWidth,
Qt::IgnoreAspectRatio,
Qt::SmoothTransformation);
//The height of the item should be a item icon size and two text lines.
m_itemHeight=m_itemWidth+(fontMetrics().height()<<1);
//Link the search.
connect(knMusicGlobal->search(), &KNMusicSearchBase::requireSearch,
this, &KNMusicAlbumView::onActionSearch);
//Set the search shortcut.
QAction *searchAction=new QAction(this);
searchAction->setShortcut(QKeySequence(Qt::CTRL+Qt::Key_F));
searchAction->setShortcutContext(Qt::WidgetWithChildrenShortcut);
connect(searchAction, &QAction::triggered,
[=]
{
//Check whether the search plugin is loaded.
if(knMusicGlobal->search())
{
knMusicGlobal->search()->onActionSearchShortcut(this);
}
});
addAction(searchAction);
//Link the locale manager.
knI18n->link(this, &KNMusicAlbumView::retranslate);
retranslate();
}
示例15: CustomProxy
CustomProxy(QGraphicsItem *parent = 0, Qt::WindowFlags wFlags = 0) : QGraphicsProxyWidget(parent, wFlags)
{
setFocusPolicy(Qt::StrongFocus);
}