bool DialogMsg::ShowUIOKDoNotShowOption( const QString& title,const QString& msg ) { QCheckBox * checkBox = new QCheckBox( tr( "do not show this dialog again" ),this ) ; this->setFixedSize( 270,110 ) ; checkBox->setGeometry( 30,40,251,31 ) ; m_ui->label->setGeometry( 10,10,251,31 ) ; m_ui->label->setFixedSize( m_ui->label->size() ) ; m_ui->pbOk->setGeometry( 100,70,75,31 ) ; m_ui->pbYes->setHidden( true ) ; m_ui->pbNo->setHidden( true ) ; m_ui->pbOk->setHidden( false ) ; this->HideLabels() ; this->ShowUI( title,msg ) ; bool st = checkBox->isChecked() ; checkBox->deleteLater() ; return st ; }
egx_wnd_t egx_checkbox_create_(int res_id,char *name,egx_uint32_t style,int x,int y,int width,int height,egx_wnd_t parent) { QCheckBox *button = new QCheckBox((QWidget*)(parent)); button->setText(QString::fromLocal8Bit(name)); if(x == 0 || y == 0){ button->resize(width,height); }else{ button->setGeometry(x,y,width,height); } return HWND_TO_GUIWND(button); }
void ProcessingPipeline::upClicked( int id ) { if( !isVeryTopElement( id ) ) { int actualID = findId( currentProcessingStepOrder, id ); int oneButtonUpID = actualID - 1; std::swap( currentProcessingStepOrder[ actualID ], currentProcessingStepOrder[ oneButtonUpID ] ); actualID = getActualID( actualID ); oneButtonUpID = getActualID( oneButtonUpID ); // swap the down button positions QPushButton * clickedButtonDown = processingPipelineConfigWidget->getDownButtonById( actualID ); QRect tempPosDown = clickedButtonDown->geometry(); QPushButton * toSwapWithButtonDown = processingPipelineConfigWidget->getDownButtonById( oneButtonUpID ); clickedButtonDown->setGeometry( toSwapWithButtonDown->geometry() ); toSwapWithButtonDown->setGeometry( tempPosDown ); // swap the up button position QPushButton * clickedButtonUp = processingPipelineConfigWidget->getUpButtonByID( actualID ); QRect tempPosUp = clickedButtonUp->geometry(); QPushButton * toSwapWithButtonUp = processingPipelineConfigWidget->getUpButtonByID( oneButtonUpID ); clickedButtonUp->setGeometry( toSwapWithButtonUp->geometry() ); toSwapWithButtonUp->setGeometry( tempPosUp ); // swap labels QLabel * clickedLabel = processingPipelineConfigWidget->getLabelByID( actualID ); QRect tempPosLabel = clickedLabel->geometry(); QLabel * toSwapWithLabel = processingPipelineConfigWidget->getLabelByID( oneButtonUpID ); clickedLabel->setGeometry( toSwapWithLabel->geometry() ); toSwapWithLabel->setGeometry( tempPosLabel ); // config button QPushButton * clickedButtonConfig = processingPipelineConfigWidget->getConfigButtonByID( actualID ); QRect tempPosConfig = clickedButtonConfig->geometry(); QPushButton * toSwapWithButtonConfig = processingPipelineConfigWidget->getConfigButtonByID( oneButtonUpID ); clickedButtonConfig->setGeometry( toSwapWithButtonConfig->geometry() ); toSwapWithButtonConfig->setGeometry( tempPosConfig ); // checkbox QCheckBox * clickedCheckBox = processingPipelineConfigWidget->getCheckBoxByID( actualID ); QRect tempPosCheckbox = clickedCheckBox->geometry(); QCheckBox * toSwapWithCheckbox = processingPipelineConfigWidget->getCheckBoxByID( oneButtonUpID ); clickedCheckBox->setGeometry( toSwapWithCheckbox->geometry() ); toSwapWithCheckbox->setGeometry( tempPosCheckbox ); } }
void MusicSoundKMicroSettingPopWidget::initWidget() { setFixedSize(54, 24); setTranslucentBackground(); m_recordCore = nullptr; m_containWidget->setFixedSize(310, 190); m_containWidget->setStyleSheet(MusicUIObject::MBackgroundStyle08 + MusicUIObject::MColorStyle03); QCheckBox *checkBox = new QCheckBox(tr("Hear Yourself Singing"), m_containWidget); checkBox->setGeometry(10, 20, 280, 25); checkBox->setStyleSheet(MusicUIObject::MCheckBoxStyle05); QCheckBox *checkBox2 = new QCheckBox(tr("Noise Elimination"), m_containWidget); checkBox2->setGeometry(10, 50, 280, 25); checkBox2->setStyleSheet(MusicUIObject::MCheckBoxStyle05); #ifdef Q_OS_UNIX checkBox->setFocusPolicy(Qt::NoFocus); checkBox2->setFocusPolicy(Qt::NoFocus); #endif QLabel *microIconLabel = new QLabel(m_containWidget); microIconLabel->setGeometry(10, 92, 26, 18); QSlider *slider = new QSlider(Qt::Horizontal, m_containWidget); slider->setGeometry(36, 90, 150, 25); slider->setStyleSheet(QString("QSlider{%1}").arg(MusicUIObject::MBackgroundStyle01) + MusicUIObject::MSliderStyle01); slider->setRange(0, 100); slider->setValue(100); connect(slider, SIGNAL(valueChanged(int)), SLOT(volumeChanged(int))); QLabel *inputLabel = new QLabel(tr("Input"), m_containWidget); inputLabel->setGeometry(10, 120, 50, 25); inputLabel->setStyleSheet(MusicUIObject::MBackgroundStyle01); m_inputComboBox = new QComboBox(m_containWidget); m_inputComboBox->setGeometry(60, 120, 230, 25); m_inputComboBox->setStyleSheet(MusicUIObject::MBorderStyle04); m_inputComboBox->setItemDelegate(new QStyledItemDelegate(m_inputComboBox)); m_inputComboBox->view()->setStyleSheet(MusicUIObject::MScrollBarStyle01); foreach(const QAudioDeviceInfo &info, QAudioDeviceInfo::availableDevices(QAudio::AudioInput)) { m_inputComboBox->addItem(info.deviceName()); }
void MainWindow::addLevelCheckBox(QWidget * iParent, int iLevel, QString iLabel) { int nboxes = (int)m_levelCheckBoxes.size(); QCheckBox * checkBox = new QCheckBox(iParent); //checkBox->setChecked(Qt::Checked); checkBox->setChecked(Qt::Unchecked); checkBox->setGeometry(QRect(10, 10 + nboxes*30, 80, 20)); if (!iLabel.isEmpty()) { checkBox->setText(iLabel); } else { checkBox->setText("level" + QString::number(iLevel)); } //checkBox->setProperty("idx", iLevel); checkBox->setProperty("idx", nboxes); checkBox->setChecked(true); checkBox->show(); m_levelCheckBoxes.push_back(checkBox); connect(checkBox, SIGNAL(clicked()), this, SLOT(levelCheckBoxModified())); }
int main(int argc, char *argv[]) { QApplication app(argc, argv); /* 常數們 */ int boardSize = BOARD_SIZE; int stoneSize = STONE_SIZE; int boardWidth = stoneSize*boardSize; /* 新視窗 */ QWidget *window = new QMouseEventWindow; window->setWindowTitle("ReversiGrid"); window->setFixedSize(boardWidth+200, boardWidth); QWidget *board = new QWidget(window); board->setFixedSize(boardWidth, boardWidth); /* 載入棋子圖片 */ QPixmap *stoneWPix = new QPixmap(":/img/stoneW.png"); QPixmap *stoneWPixS = new QPixmap; *stoneWPixS = stoneWPix->scaled(stoneSize, stoneSize, Qt::IgnoreAspectRatio, Qt::SmoothTransformation); QPixmap *stoneBPix = new QPixmap(":/img/stoneB.png"); QPixmap *stoneBPixS = new QPixmap; *stoneBPixS = stoneBPix->scaled(stoneSize, stoneSize, Qt::IgnoreAspectRatio, Qt::SmoothTransformation); QPixmap *stoneWaPix = new QPixmap(":/img/stoneWa.png"); QPixmap *stoneWaPixS = new QPixmap; *stoneWaPixS = stoneWaPix->scaled(stoneSize, stoneSize, Qt::IgnoreAspectRatio, Qt::SmoothTransformation); QPixmap *stoneBaPix = new QPixmap(":/img/stoneBa.png"); QPixmap *stoneBaPixS = new QPixmap; *stoneBaPixS = stoneBaPix->scaled(stoneSize, stoneSize, Qt::IgnoreAspectRatio, Qt::SmoothTransformation); QPixmap *stoneWsPix = new QPixmap(":/img/stoneWs.png"); QPixmap *stoneWsPixS = new QPixmap; *stoneWsPixS = stoneWsPix->scaled(stoneSize, stoneSize, Qt::IgnoreAspectRatio, Qt::SmoothTransformation); QPixmap *stoneBsPix = new QPixmap(":/img/stoneBs.png"); QPixmap *stoneBsPixS = new QPixmap; *stoneBsPixS = stoneBsPix->scaled(stoneSize, stoneSize, Qt::IgnoreAspectRatio, Qt::SmoothTransformation); QPixmap *nullPix = new QPixmap(":/img/null.png"); /* 棋盤網格排版 */ QGridLayout *grid = new QGridLayout; grid->setSpacing(0); grid->setMargin(0); grid->setGeometry(QRect(0, 0, 10, 100)); /* 構建棋盤 */ QLabel *square[BOARD_SIZE*BOARD_SIZE]; for (int i=0; i<boardSize; i++) { for (int j=0; j<boardSize; j++) { square[i*BOARD_SIZE+j] = new QLabel; square[i*BOARD_SIZE+j]->setFrameStyle(QFrame::Panel + QFrame::Sunken); square[i*BOARD_SIZE+j]->setAlignment(Qt::AlignCenter); square[i*BOARD_SIZE+j]->setAttribute(Qt::WA_TranslucentBackground); // square[i*BOARD_SIZE+j]->setPixmap(); square[i*BOARD_SIZE+j]->setAttribute(Qt::WA_TransparentForMouseEvents, true); grid->addWidget(square[i*BOARD_SIZE+j], i, j); } } QLabel *turnT = new QLabel(window); turnT->setGeometry(boardWidth, 20, 200, 14); turnT->setText("<center>Next move:</center>"); QLabel *turn = new QLabel(window); turn->setGeometry(boardWidth+100-(STONE_SIZE/2), 45, STONE_SIZE, STONE_SIZE); turn->setFrameStyle(QFrame::Sunken); /* 遊戲物件 */ game = new Game(square, turn, stoneWPixS, stoneBPixS, stoneWaPixS, stoneBaPixS, stoneWsPixS, stoneBsPixS, nullPix); /* UI */ QCheckBox *hintCheckBox = new QCheckBox("Show hints"); hintCheckBox->setParent(window); hintCheckBox->setGeometry(boardWidth+50, 210, 100, 20); QObject::connect(hintCheckBox, SIGNAL(stateChanged(int)), game, SLOT(hintSwitch(int))); QLabel *bScore = new QLabel(window); bScore->setGeometry(boardWidth, 100, 200, 14); bScore->setText("<center>Black</center>"); QLabel *wScore = new QLabel(window); wScore->setGeometry(boardWidth, 150, 200, 14); wScore->setText("<center>White</center>"); QLCDNumber *lcdB = new QLCDNumber(window); QLCDNumber *lcdW = new QLCDNumber(window); lcdB->setGeometry(boardWidth+50, 120, 100, 24); lcdW->setGeometry(boardWidth+50, 170, 100, 24); QObject::connect(game, SIGNAL(updateBScore(int)), lcdB, SLOT(display(int))); QObject::connect(game, SIGNAL(updateWScore(int)), lcdW, SLOT(display(int))); QCheckBox *aiBCheckBox = new QCheckBox("AI"); aiBCheckBox->setParent(window); aiBCheckBox->setGeometry(boardWidth+140, 100, 50, 14); QObject::connect(aiBCheckBox, SIGNAL(stateChanged(int)), game, SLOT(aiBSwitch(int))); QCheckBox *aiWCheckBox = new QCheckBox("AI"); aiWCheckBox->setParent(window); aiWCheckBox->setGeometry(boardWidth+140, 150, 50, 14); QObject::connect(aiWCheckBox, SIGNAL(stateChanged(int)), game, SLOT(aiWSwitch(int))); /* 按鍵 */ QPushButton *undoBtn = new QPushButton("Undo"); undoBtn->setParent(window); undoBtn->setGeometry(boardWidth+140, 64, 42, 22); undoBtn->setEnabled(false); QObject::connect(undoBtn, SIGNAL(clicked()), game, SLOT(undo())); QObject::connect(game, SIGNAL(undoAvai(bool)), undoBtn, SLOT(setEnabled(bool))); QPushButton *restartBtn = new QPushButton("Restart"); restartBtn->setParent(window); restartBtn->setGeometry(boardWidth+50, 242, 100, 36); QObject::connect(restartBtn, SIGNAL(clicked()), game, SLOT(reset())); QPushButton *exitBtn = new QPushButton("Exit"); exitBtn->setParent(window); exitBtn->setGeometry(boardWidth+50, 272, 100, 36); QObject::connect(exitBtn, SIGNAL(clicked()), &app, SLOT(quit())); /* 計時器 */ QTimer *update = new QTimer; update->start(10); QObject::connect(update, SIGNAL(timeout()), game, SLOT(update())); /* 準備視窗 */ board->setLayout(grid); window->setMouseTracking(true); window->show(); game->reset(); return app.exec(); }