int main(int argc,char** argv){ QApplication app(argc,argv); /* 定义父窗口 并调整大小 显示 */ QDialog *parent=new QDialog(); parent->resize(400,300); /* 定义父窗口中的组件指针 */ QLineEdit *username; QLineEdit *userpasswd; QPushButton *blogin; QPushButton *bcancel; /* 赋值 */ username=new QLineEdit(parent); userpasswd=new QLineEdit(parent); blogin=new QPushButton("login",parent); bcancel=new QPushButton("cancel",parent); /* 调整组件的位置 */ username->move(200,50); userpasswd->move(200,100); blogin->move(50,200); bcancel->move(250,200); parent->show(); /* 点击cancel按钮 关闭父窗口 */ QObject::connect(bcancel, SIGNAL(clicked()),parent,SLOT(close())); return app.exec(); }
void FadeMessage::setupScene() { QGraphicsRectItem *parent = m_scene.addRect(0, 0, 800, 600); parent->setPen(Qt::NoPen); parent->setZValue(0); QGraphicsPixmapItem *bg = m_scene.addPixmap(QPixmap(":/background.jpg")); bg->setParentItem(parent); bg->setZValue(-1); for (int i = 1; i < 5; ++i) for (int j = 2; j < 5; ++j) { QGraphicsRectItem *item = m_scene.addRect(i * 50, (j - 1) * 50, 38, 38); item->setParentItem(parent); item->setZValue(1); int hue = 12 * (i * 5 + j); item->setBrush(QColor::fromHsv(hue, 128, 128)); } QFont font; font.setPointSize(font.pointSize() * 2); font.setBold(true); QFontMetrics fontMetrics(font); int fh = fontMetrics.height(); QString sceneText = "Qt Everywhere!"; int sceneTextWidth = fontMetrics.width(sceneText); QGraphicsRectItem *block = m_scene.addRect(50, 300, sceneTextWidth, fh + 3); block->setPen(Qt::NoPen); block->setBrush(QColor(102, 153, 51)); QGraphicsTextItem *text = m_scene.addText(sceneText, font); text->setDefaultTextColor(Qt::white); text->setPos(50, 300); block->setZValue(2); block->hide(); text->setParentItem(block); m_message = block; m_effect = new QGraphicsColorizeEffect; m_effect->setColor(QColor(122, 193, 66)); m_effect->setStrength(0); m_effect->setEnabled(true); parent->setGraphicsEffect(m_effect); QPushButton *press = new QPushButton; press->setText(tr("Press me")); connect(press, SIGNAL(clicked()), SLOT(togglePopup())); m_scene.addWidget(press); #if defined(Q_WS_S60) || defined(Q_WS_MAEMO_5) press->move(200, 210); #else press->move(300, 500); #endif }
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow), m_clicks(0) { ui->setupUi(this); connect(ui->actionExit, SIGNAL(triggered()), this, SLOT(close())); connect(ui->lineEdit, SIGNAL(textChanged(QString)), ui->textEditDisplay, SLOT(setText(QString))); connect(ui->textEdit, SIGNAL(textChanged()), this, SLOT(updateTextEditDisplay())); connect(ui->pushButton, SIGNAL(pressed()), this, SLOT(updatePushButtonDisplay())); connect(ui->pushButton, SIGNAL(released()), this, SLOT(updatePushButtonDisplay())); connect(ui->pushButton, SIGNAL(clicked()), this, SLOT(updateClickCount())); connect(ui->radioButton1, SIGNAL(toggled(bool)), this, SLOT(updateRadioButtonDisplay())); connect(ui->radioButton2, SIGNAL(toggled(bool)), this, SLOT(updateRadioButtonDisplay())); connect(ui->checkBox, SIGNAL(stateChanged(int)), this, SLOT(updateCheckBoxDisplay())); connect(ui->comboBox, SIGNAL(activated(int)), this, SLOT(updateComboBoxDisplay())); connect(ui->horizontalSlider, SIGNAL(valueChanged(int)), this, SLOT(updateHorizontalSliderDisplay())); QWidget *contents = new QWidget; contents->setObjectName("contents"); contents->setFixedSize(QSize(500, 500)); QPushButton *topLeft = new QPushButton(contents); topLeft->setObjectName("topLeft"); topLeft->setFixedSize(QSize(20,20)); topLeft->move(10, 10); QPushButton *topRight = new QPushButton(contents); topRight->setObjectName("topRight"); topRight->setFixedSize(QSize(20,20)); topRight->move(470, 10); QPushButton *bottomLeft = new QPushButton(contents); bottomLeft->setObjectName("bottomLeft"); bottomLeft->setFixedSize(QSize(20,20)); bottomLeft->move(10, 470); QPushButton *bottomRight = new QPushButton(contents); bottomRight->setObjectName("bottomRight"); bottomRight->setFixedSize(QSize(20,20)); bottomRight->move(470, 470); ui->scrollArea->setWidget(contents); QStandardItemModel *model = new QStandardItemModel(this); model->setHorizontalHeaderLabels(QStringList() << tr("items")); QStandardItem *parentItem; for (int j = 0; j < 3; ++j) { parentItem = model->invisibleRootItem(); for (int i = 0; i < 4; ++i) { QStandardItem *item = new QStandardItem(QString("item %0").arg(i)); parentItem->appendRow(item); parentItem = item; } } ui->treeView->setModel(model); }
void Carrefour::getConfiguration(Position * p) { QWidget * configWidget = new QWidget(); this->config->setQWidget(configWidget); int taille = 50; std::list<Route *>::iterator itRoutes; for (itRoutes = this->routes.begin() ; itRoutes != this->routes.end() ; itRoutes++) { Route * route = (Route *) *itRoutes; if (*(route->getPosition()) == *p) { this->config->setRoute(route); QLabel * label = new QLabel("Route", configWidget); label->move(200, taille); taille += 50; } } std::list<Vehicule *>::iterator itVehicule; for (itVehicule = this->objetRoutes.begin() ; itVehicule != this->objetRoutes.end() ; itVehicule++) { Vehicule * vehicule = (Vehicule *) *itVehicule; if (*(vehicule->getPosition()) == *p) { this->config->setVehicule(vehicule); QLabel * label = new QLabel(QString::fromStdString(vehicule->getType()), configWidget); label->move(200, taille); taille += 50; QLabel * labelPositionArrivee = new QLabel("Position d'arrivee", configWidget); labelPositionArrivee->move(50, taille); QLabel * labelX = new QLabel("X : ", configWidget); labelX->move(150, taille); QTextEdit * xTextEdit = new QTextEdit(configWidget); xTextEdit->move(180, taille); xTextEdit->setFixedSize(50, 30); this->config->setXTextEdit(xTextEdit); QLabel * labelY = new QLabel("Y : ", configWidget); labelY->move(250, taille); QTextEdit * yTextEdit = new QTextEdit(configWidget); yTextEdit->move(280, taille); yTextEdit->setFixedSize(50, 30); this->config->setYTextEdit(yTextEdit); taille += 50; QLabel * labelNbVehicule = new QLabel("Nb vehicule : ", configWidget); labelNbVehicule->move(50, taille); QTextEdit * nbVehiculeTextEdit = new QTextEdit(configWidget); nbVehiculeTextEdit->move(150, taille); nbVehiculeTextEdit->setFixedSize(50, 30); taille += 50; } } QPushButton * valideButton = new QPushButton("valide", configWidget); QObject::connect(valideButton, SIGNAL(clicked()), this, SLOT(valideConfig())); valideButton->move(100, taille); QPushButton * annuleButton = new QPushButton("annule", configWidget); QObject::connect(annuleButton, SIGNAL(clicked()), this, SLOT(annuleConfig())); annuleButton->move(300, taille); configWidget->show(); }
void MyScrollAreaWidget::test4f() { m_ScrollAreaWidgetContents = new QWidget; m_ScrollAreaWidgetContents->setGeometry(0, 0, 200, 1000); m_ScrollAreaWidgetContents->setMinimumSize(200, 1000); QPushButton* pBtn = new QPushButton(m_ScrollAreaWidgetContents); pBtn->setGeometry(0, 0, 200, 30); pBtn->setMinimumSize(200, 30); pBtn->show(); //pPnt->setWidget(pBtn); pBtn = new QPushButton(m_ScrollAreaWidgetContents); pBtn->setGeometry(0, 30, 200, 30); pBtn->setMinimumSize(200, 30); pBtn->move(0, 30); pBtn->show(); //pPnt->setWidget(pBtn); pBtn = new QPushButton(m_ScrollAreaWidgetContents); pBtn->setGeometry(0, 60, 200, 30); pBtn->setMinimumSize(200, 30); pBtn->show(); //pPnt->setWidget(pBtn); this->setWidget(m_ScrollAreaWidgetContents); }
int main(int argc,char** argv){ QApplication app(argc,argv); QDialog *parent; QLineEdit *add; QLabel *oper; QLineEdit *added; QPushButton *equ; QLineEdit *res; /* 指针赋值 */ parent=new QDialog(); parent->resize(650,300); /* 给界面中组件指针赋值 */ add=new QLineEdit(parent); oper=new QLabel("+",parent); added=new QLineEdit(parent); equ=new QPushButton("=",parent); res=new QLineEdit(parent); /* 调整位置 */ add->move(20,130); oper->move(170,130); added->move(220,130); equ->move(360,130); res->move(470,130); parent->show(); return app.exec(); }
void gesamtbild::zeitanzeige(/*int dora, int hin, int may*/) { qWarning() << "Zeit"; QDialog *zeitw = new QDialog(this); QVBoxLayout layout(zeitw); QLabel *anzeige = new QLabel(tr("Time: Day %1,").arg(GAMEDATA->gametime().day()).append(QString("%1 hours").arg(GAMEDATA->gametime().hour())), zeitw); // anzeige->setText(anzeige->text().append(QString(", %2 Uhr %3").arg( gameview->stunde, gameview->minute)));gameview->stunde // qWarning() << anzeige->text().append(QString(", %2 Uhr %3").arg( gameview->stunde, gameview->minute)); QPushButton *ok = new QPushButton("Ok",zeitw); ok->move(50, 50); layout.addWidget(anzeige); layout.addWidget(ok); // zeitw->setGeometry(width()/2,height()/2,200,100); zeitw->setLayout(&layout); zeitw->setAutoFillBackground(true); zeitw->move(gameview->width()/2,gameview->height()/2); zeitw->raise(); zeitw->show(); connect(ok, SIGNAL(clicked()), gameview, SLOT(endePause())); connect(ok, SIGNAL(clicked()), zeitw, SLOT(close())); connect(ok, SIGNAL(clicked()), zeitw, SLOT(deleteLater())); }
int main(int argc,char** argv){ QApplication app(argc,argv); QDialog *parent=new QDialog(); parent->resize(650,200); /* 定义父窗口中的组件指针 */ QLineEdit *add; QLabel *oper; QLineEdit *added; QPushButton *equ; QLineEdit *res; /* 赋值 */ add=new QLineEdit(parent); oper=new QLabel("+",parent); added=new QLineEdit(parent); equ=new QPushButton("=",parent); res=new QLineEdit(parent); /* 调整组件的位置 */ add->move(20,80); oper->move(170,80); added->move(220,80); equ->move(370,80); res->move(480,80); parent->show(); return app.exec(); }
QGraphicsItem *WallpaperChange::item() { QPushButton *button = new QPushButton("Change Wallpaper", 0); button->move(10, 10); connect(button, SIGNAL(clicked(bool)), this, SLOT(changeWallpaper(bool))); return new WallpaperWidget(QRectF(0, 0, 340, 240), button); }
Widget::Widget(QWidget *parent) : QWidget(parent), ui(new Ui::Widget) { ui->setupUi(this); QPushButton *btn ;//= new QPushButton(this); QList <QPushButton*> list; QList<QString> list1; QStringList list2; list2<<"aa"<<"bb"<<"cc"<<"dd"; list2.append("aa"); list2[2]="zz"; for(int i=0; i<10; i++) { btn = new QPushButton(this); btn->move(0, i*20); list.append(btn); if(list2.length()>i) btn->setText(list2.at(i)); } list.clear(); }
void CustomMessageBox::displayNewUpdate() { setFixedSize(434, 179); _label->setText("Une version plus récente de Multifacile est disponible, veux-tu la télécharger ?"); _label->setWordWrap(true); _label->move(45, 50); _menu->move(376, 0); _okBouton->setText(tr("Oui")); _okBouton->move(346, 135); QPushButton *No = new QPushButton(tr("Non"), this); No->setAttribute(Qt::WA_TranslucentBackground); No->move(386, 140); No->setObjectName("NoButton"); No->setStyleSheet("QPushButton#NoButton{background-color: rgba(255, 255, 255, 0);color: rgb(144,191,79); background-image: url(none);}"); disconnect(_okBouton, SIGNAL(clicked()), this, SLOT(close())); connect(_okBouton, SIGNAL(clicked()), this, SLOT(accept())); connect(No, SIGNAL(clicked()), this, SLOT(reject())); }
void HorizontalTabWidget::setCurrentIndex(int index) { int xPos = 0; for(unsigned i = 0; i < m_tabButtons.size(); i++) { QPushButton * button = m_tabButtons[i]; QString style; style.append("QPushButton { border: none; background-color: #808080; "); style.append(" border-right: 1px solid black;"); style.append(" border-bottom: 1px solid black;"); style.append(" padding-left: 10px;"); style.append(" padding-right: 10px;"); style.append(" padding-top: 5px;"); style.append(" font: bold;"); if( i == m_tabButtons.size() - 1 ) { style.append(" border-right: none;"); } style.append("}"); button->setStyleSheet(style); button->adjustSize(); button->move(xPos,0); xPos = xPos + button->width(); } m_tabBarLine->setFixedWidth(xPos); m_tabBarLine->raise(); QPushButton * button = m_tabButtons[index]; QString style; // NOTE: Yellow Orange Lighter #fdbc3b and the Darker Orange is #f47920 style.append("QPushButton { border: none; background-color: #f47920; "); style.append(" border-right: 1px solid black;"); style.append(" padding-left: 10px;"); style.append(" padding-right: 10px;"); style.append(" padding-top: 5px;"); style.append(" font: bold;"); if( index == int(m_tabButtons.size() - 1) ) { style.append(" border-right: none;"); } style.append("}"); button->setStyleSheet(style); button->raise(); emit tabSelected(m_ids[index]); }
void HorizontalTabWidget::setCurrentIndex(int index) { int xPos = 0; for(unsigned i = 0; i < m_tabButtons.size(); i++) { QPushButton * button = m_tabButtons[i]; QString style; style.append("QPushButton { border: none; background-color: #808080; "); style.append(" border-right: 1px solid black;"); style.append(" border-bottom: 1px solid black;"); style.append(" padding-left: 10px;"); style.append(" padding-right: 10px;"); style.append(" padding-top: 5px;"); style.append(" color: white;"); if( i == m_tabButtons.size() - 1 ) { style.append(" border-right: none;"); } style.append("}"); button->setStyleSheet(style); button->adjustSize(); button->move(xPos,0); xPos = xPos + button->width(); } m_tabBarLine->setFixedWidth(xPos); m_tabBarLine->raise(); QPushButton * button = m_tabButtons[index]; QString style; style.append("QPushButton { border: none; background-color: #95B3DE; "); style.append(" border-right: 1px solid black;"); style.append(" padding-left: 10px;"); style.append(" padding-right: 10px;"); style.append(" padding-top: 5px;"); style.append(" color: white;"); if( index == int(m_tabButtons.size() - 1) ) { style.append(" border-right: none;"); } style.append("}"); button->setStyleSheet(style); button->raise(); m_pageStack->setCurrentIndex(index); }
void CreateMsgButton(QMainWindow* window) { QMessageBox* message = new QMessageBox(window); message->setText("Message text"); QPushButton* button = new QPushButton("Message", window); button->move(85, 40); button->resize(80, 25); button->show(); QObject::connect(button, SIGNAL(released()), message, SLOT(exec())); }
void VerticalTabWidget::setCurrentIndex(int index) { int yPos = 25; for(unsigned i = 0; i < m_tabButtons.size(); i++) { QPushButton * button = m_tabButtons[i]; button->move(0,yPos); yPos = yPos + button->height(); QString imagePath; QString style; if (i == static_cast<unsigned>(index)) { imagePath = m_selectedPixmaps[i]; // Ignore clicks to the already active tab if(currentIndex != index){ currentIndex = index; style.append("QPushButton { background-color: blue; background-image: url(\""); style.append(imagePath); style.append("\"); border: none; background-repeat: 0; }"); button->setStyleSheet(style); currentIndex = index; emit tabSelected(m_ids[index]); } } else { if (button->isEnabled()){ imagePath = m_unSelectedPixmaps[i]; style.append("QPushButton { background-image: url(\""); style.append(imagePath); style.append("\"); border: none; background-color: red; background-repeat: 0; }"); } else { imagePath = m_disabledPixmaps[i]; style.append("QPushButton { background-image: url(\""); style.append(imagePath); style.append("\"); border: none; background-color: red; background-repeat: 0; }"); } button->setStyleSheet(style); } } }
void MainTabView::setCurrentIndex(int index) { int xPos = m_tabLabel->width() + TAB_SEPARATION; for(unsigned i = 0; i < m_tabButtons.size(); i++) { QPushButton * button = m_tabButtons[i]; QString style; style.append("QPushButton { border: none; background-color: #BBCDE3; "); style.append(" border-right: 1px solid black;"); style.append(" border-bottom: 1px solid black;"); style.append(" border-top: 1px solid black;"); style.append(" border-left: 1px solid black;"); style.append(" border-top-left-radius: 5px;"); style.append(" border-top-right-radius: 5px;"); style.append(" padding-left: 10px;"); style.append(" padding-right: 10px;"); style.append(" color: black;"); style.append("}"); button->setStyleSheet(style); button->adjustSize(); button->move(xPos,5); button->stackUnder(m_mainWidget); xPos += TAB_SEPARATION + button->width(); } QPushButton * button = m_tabButtons[index]; QString style; style.append("QPushButton { border: none; background-color: #E6E6E6; "); style.append(" border-right: 1px solid black;"); style.append(" border-bottom: none;"); style.append(" border-top: 1px solid black;"); style.append(" border-left: 1px solid black;"); style.append(" border-top-left-radius: 5px;"); style.append(" border-top-right-radius: 5px;"); style.append(" padding-left: 10px;"); style.append(" padding-right: 10px;"); style.append(" color: black;"); style.append("}"); button->setStyleSheet(style); button->raise(); m_stackedWidget->setCurrentIndex(index); emit tabSelected(m_ids[index]); }
MyIRC::MyIRC(QWidget *mainWindow) { this->mainWindow = static_cast<test*>(mainWindow); //widget community. this->session = new MySession(this); this->controller = new WindowController(this); QPushButton *actConnect = new QPushButton("connect", mainWindow); connect(actConnect, SIGNAL(clicked()), this, SLOT(connectToServer())); actConnect->move(760, 0); //this->mainWindow->getUi()->mainToolBar->addAction(actConnect); QPushButton *actDisConnect = new QPushButton("Disconnect", mainWindow); connect(actDisConnect, SIGNAL(clicked()), this, SLOT(disconnectFromServer())); //this->mainWindow->getUi()->mainToolBar->addAction(actDisConnect); actDisConnect->move(834, 0); QPushButton *actSetNickname = new QPushButton("Set Nickname", mainWindow); connect(actSetNickname, SIGNAL(clicked()), this, SLOT(setNickname())); actSetNickname->move(930, 0); //this->mainWindow->getUi()->mainToolBar->addAction(actSetNickname); }
void RunGame::updateImage() { // 获得 widget 的大小 int widgetWidth = ui->widget->width(); int widgetHeight = ui->widget->height(); // 获得图片可能的尺寸 int imageWidth = widgetWidth / m_colNumber; int imageHeight = widgetHeight / m_rowNumber; // 使用最小的尺寸 if (imageWidth > imageHeight) { imageWidth = imageHeight; } imageHeight = imageWidth; // 获得top与left坐标 int x = (widgetWidth - imageWidth * m_colNumber) / 2; int y = (widgetHeight - imageHeight * m_rowNumber) / 2; m_imageBtnWidth = imageWidth; m_imageBtnHeight = imageHeight; m_imageBtnTop = y; m_imageBtnLeft = x; for (int i = 0; i < m_colNumber; i++) { for (int j = 0; j < m_rowNumber; j++) { int value = m_core.GetCell(j+1, i+1); if (CELL_NO_HAS_IMAGE != value) { QPushButton * btn = m_imageBtns[j*m_colNumber + i]; btn->setFocusPolicy(Qt::NoFocus); btn->resize(QSize(imageWidth, imageHeight)); btn->move(x + imageWidth * i, y + imageHeight * j); btn->setProperty(BTN_IMAGE_VALUE, value); QPixmap image; QString imageFile = QString("%1.png").arg(value); image.load(m_imageFileFamily + imageFile); btn->setIcon(image); btn->setIconSize(QSize(imageWidth - 6, imageHeight - 6)); btn->show(); connect(btn, SIGNAL(clicked()), this, SLOT(on_btn_image_clicked())); } } } }
int main(int argc, char *argv[]) { QApplication app(argc, argv); QWidget *window = new QWidget(); window->resize(320, 240); window->setWindowTitle(tr("Child widget")); window->show(); //! [create, position and show] QPushButton *button = new QPushButton(tr("Press me"), window); button->move(100, 100); button->show(); //! [create, position and show] return app.exec(); }
int main(int argc, char *argv[]) { QApplication app(argc, argv); QWidget window; window.resize(320, 240); window.setWindowTitle(QApplication::translate("childwidget", "Child widget")); window.show(); //! [create, position and show] QPushButton *button = new QPushButton( QApplication::translate("childwidget", "Press me"), &window); button->move(100, 100); button->show(); //! [create, position and show] return app.exec(); }
int main(int argc, char *argv[]) { QApplication app(argc, argv); //----------------------- QWidget MainWindows; MainWindows.setStyleSheet( " QWidget { font-size: 17px; color :#65ED64; background-color: #777777; border: 7px solid #64EB8D; }" ); //----------------------- QLabel *ptLabel = new QLabel(&MainWindows); QPushButton *ptButton = new QPushButton(&MainWindows); Counter counter; ptLabel->move(25,25); ptLabel->setText(" T"); ptLabel->resize(150,150); ptLabel->setStyleSheet( "QLabel { font-size: 80px; color :#65ED64; background-color: #0C9F1D; border: 7px solid #64EB8D; }" ); ptButton->move(180,25); ptButton->setText(" Add "); ptButton->resize(150,150); ptButton->setStyleSheet( "QPushButton { font-size: 40px; color :#65ED64; background-color: #0C9F1D; border: 7px solid #64EB8D; }" ); // label.show(); // button.show(); QObject::connect(ptButton, SIGNAL(clicked()), &counter, SLOT(slotInc()) ); QObject::connect(&counter, SIGNAL(counterChanged(int)), ptLabel, SLOT(setNum(int)) ); QObject::connect(&counter, SIGNAL(goodbye()), &app, SLOT(quit()) ); MainWindows.resize(350, 200); MainWindows.show(); return app.exec(); }
HTMLChatEditFrame::HTMLChatEditFrame(QWidget* parent, const QString& iconPath) : QWidget(parent) { QPushButton * linkBtn = new QPushButton("link", this); toolBar = new QToolBar(this); toolBar->setIconSize(QSize(16, 16)); linkBtn->move(450, 40); editor = new HTMLChatEdit(this, toolBar, iconPath); editor->setGeometry(0, 30, 400, 150); this->setGeometry(0, 0, 600, 400); this->show(); QObject::connect(linkBtn, SIGNAL(clicked()), editor, SLOT(insertAnchor())); QObject::connect(linkBtn, SIGNAL(clicked()), editor, SLOT(insertImage())); }
void ctkExampleDicomAppLogic::do_something() { QPushButton *button = new QPushButton("Button from App"); try { QRect preferred(50,50,100,100); qDebug() << " Asking:getAvailableScreen"; QRect rect = host->getAvailableScreen(preferred); qDebug() << " got sth:" << rect.top(); button->move(rect.topLeft()); button->resize(rect.size()); } catch (const std::runtime_error& e) { qCritical() << e.what(); } button->show(); }
ToolTipWidget::ToolTipWidget(QWidget *parent /* = 0 */) :QWidget(parent) { this->setFixedSize(80, 60); QPalette pal(this->palette()); pal.setColor(QPalette::Background, Qt::black); //ÉèÖñ³¾°ºÚÉ« this->setAutoFillBackground(true); this->setPalette(pal); //this->setWindowFlags(Qt::Widget | Qt::Popup); QPushButton *btn = new QPushButton(this); btn->setText("Button"); btn->move(5,20); btn->show(); }
void qmainstackwidget::set_editsearch() { edit_search = new QLineEdit(this); edit_search->setGeometry(0, 110, 283, 25); edit_search->setFont(QFont("Timers", 10, QFont::StyleOblique)); edit_search->setStyleSheet("QLineEdit{border: 2px solid rgb(22, 154, 218);padding: 0 8px;background: rgb(21, 127, 178);selection-background-color: darkgray;color:rgb(240, 255, 255);}"); QPushButton *search = new QPushButton(this); search->setFlat(true); QPixmap pix; pix.load("search.jpg"); pix = pix.scaled(18, 18); QIcon icon_search(pix); search->setIcon(icon_search); search->setFixedSize(18, 18); search->move(edit_search->width() - search->width() - 2, (edit_search->height() - search->height()) / 2); search->setGeometry(263, 115, search->width(), search->height()); search->setStyleSheet("QPushButton{ border-image:url(search.png); }" "QPushButton:press{border-image:url(search_press.png);}" "QPushButton:hover{border-image:url(search_hover.png);}"); search->setCursor(QCursor(Qt::PointingHandCursor)); }
//-------------------------------------------------------------------------- static int idaapi ui_callback(void *user_data, int notification_code, va_list va) { if ( notification_code == ui_tform_visible ) { TForm *form = va_arg(va, TForm *); if ( form == user_data ) { QWidget *w = (QWidget *)form; MyActions *actions = new MyActions(w); // create a widget QPushButton *b = new QPushButton("Click here", w); // connect the button to a slot QObject::connect(b, SIGNAL(clicked()), actions, SLOT(clicked())); // position and display it b->move(50, 50); b->show(); msg("Qt form is displayed\n"); } }
MainWindow::MainWindow(QWidget* parent) : QWidget(parent, Qt::Dialog), _isFileOpen(false) { setWindowTitle("Binarization"); setMinimumSize(220, 50); _toolbar = new QWidget(this); _toolbar->resize(width(), 25); QPushButton* openFileButton = new QPushButton("&Open", _toolbar); openFileButton->move(2, 2); connect(openFileButton, SIGNAL(clicked(bool)), SLOT(openfile())); // _gaussian = new QCheckBox("&Gaussian", this); // _gaussian->setChecked(true); // _gaussian->move(width() - _gaussian->width(), 3); // connect(_gaussian, SIGNAL(toggled(bool)), SLOT(binarize())); _cSlider = new QSlider(Qt::Horizontal, this); _cSlider->setRange(THRESH_RANGE_MIN, THRESH_RANGE_MAX); _cSlider->setValue(C_SLIDER_START_VALUE); connect(_cSlider, SIGNAL(valueChanged(int)), SLOT(binarize())); // _blockSize = new QSpinBox(_toolbar); // _blockSize->setRange(BLOCK_SIZE_MIN, BLOCK_SIZE_MAX); // _blockSize->setSingleStep(2); // _blockSize->setValue(BLOCK_SIZE_START_VALUE); // _blockSize->move(_gaussian->x() width() - _blockSize->width(), 2); // connect(_blockSize, SIGNAL(valueChanged(int)), SLOT(binarize())); _image = new QWidget(this); _progress = new QProgressBar(this); _percentInfo = new QLabel("Object is %% from the image.", this); openfile(); }
void LibraryTabWidget::setCurrentIndex(int index) { int xPos = 0; for(unsigned i = 0; i < m_tabButtons.size(); i++) { QPushButton * button = m_tabButtons[i]; button->move(xPos,0); xPos = xPos + button->width(); QString imagePath = m_unSelectedPixmaps[i]; QString style; style.append("QPushButton { background: none; background-image: url(\""); style.append(imagePath); style.append("\"); border: none; }"); button->setStyleSheet(style); } QPushButton * button = m_tabButtons[index]; QString imagePath = m_selectedPixmaps[index]; QString style; style.append("QPushButton { background: none; background-image: url(\""); style.append(imagePath); style.append("\"); border: none; background-repeat: 0; }"); button->setStyleSheet(style); m_pageStack->setCurrentIndex(index); }
void CConfigJogDialog::initLayout(void) { static const char *strLut[] = { "JointVelocity", "JointAcceleration", "ServoVelocity", "ServoAcceleration", "LinearVelocity", "LinearAcceleration", "VelocityRatio" }; static const char *unitLut[] = { "°/s", "°/(s·s)", "°/s", "°/(s·s)", "mm/s", "mm/(s·s)", "%" }; static const char *toolTipLut[] = { "Velocity of single joint", "Acceleration of single joint", "Velocity of the servo", "Acceleration of the servo", "Velocity of single axis", "Acceleration of single axis", "Ratio of the velocity" }; QFont font("微软雅黑", 8); COptions::JogParams jogParams; COptions::instance()->getJogParams(&jogParams); float *params = (float *)&jogParams; int i = 0; for (i = 0; i < 6; i++) { QLabel *label = new QLabel(this); label->move(10, 10 + i * 40); label->resize(150, 30); label->setFont(font); label->setText(strLut[i]); QLineEdit *lineEdit = new QLineEdit(this); lineEdit->move(180, 10 + i * 40); lineEdit->resize(100, 30); lineEdit->setFont(font); lineEdit->setToolTip(toolTipLut[i]); lineEdit->setText(QString("%1").arg(params[i])); paramWidgetList << lineEdit; label = new QLabel(this); label->move(300, 10 + i * 40); label->resize(50, 20); label->setFont(font); label->setText(unitLut[i]); } QPushButton *sendBtn = new QPushButton(this); sendBtn->move(280, 10 + i * 40); sendBtn->resize(120, 50); sendBtn->setFont(font); sendBtn->setText("Send"); connect(sendBtn, SIGNAL(clicked()), this, SLOT(onSendBtnClicked())); }
BitcreditGUI::BitcreditGUI(const PlatformStyle *platformStyle, const NetworkStyle *networkStyle, QWidget *parent) : QMainWindow(parent), clientModel(0), walletFrame(0), //unitDisplayControl(0), labelEncryptionIcon(0), labelConnectionsIcon(0), labelBlocksIcon(0), progressBarLabel(0), progressBar(0), progressDialog(0), appMenuBar(0), overviewAction(0), historyAction(0), quitAction(0), sendCoinsAction(0), sendCoinsMenuAction(0), usedSendingAddressesAction(0), usedReceivingAddressesAction(0), signMessageAction(0), verifyMessageAction(0), aboutAction(0), receiveCoinsAction(0), receiveCoinsMenuAction(0), optionsAction(0), toggleHideAction(0), encryptWalletAction(0), backupWalletAction(0), changePassphraseAction(0), aboutQtAction(0), openRPCConsoleAction(0), openAction(0), showHelpMessageAction(0), trayIcon(0), trayIconMenu(0), notificator(0), rpcConsole(0), helpMessageDialog(0), prevBlocks(0), spinnerFrame(0), platformStyle(platformStyle) { setFixedSize(850, 650); setWindowFlags(Qt::FramelessWindowHint); GUIUtil::restoreWindowGeometry("nWindow", QSize(850, 650), this); // load stylesheet QFile qss(":css/dyno"); qss.open(QFile::ReadOnly); qApp->setStyleSheet(qss.readAll()); qss.close(); QString windowTitle = tr(PACKAGE_NAME) + " - "; #ifdef ENABLE_WALLET /* if compiled with wallet support, -disablewallet can still disable the wallet */ enableWallet = !GetBoolArg("-disablewallet", false); #else enableWallet = false; #endif // ENABLE_WALLET if(enableWallet) { windowTitle += tr("Wallet"); } else { windowTitle += tr("Node"); } //windowTitle += " " + networkStyle->getTitleAddText(); #ifndef Q_OS_MAC QApplication::setWindowIcon(networkStyle->getTrayAndWindowIcon()); setWindowIcon(networkStyle->getTrayAndWindowIcon()); #else MacDockIconHandler::instance()->setIcon(networkStyle->getAppIcon()); #endif setWindowTitle(windowTitle); #if defined(Q_OS_MAC) && QT_VERSION < 0x050000 // This property is not implemented in Qt 5. Setting it has no effect. // A replacement API (QtMacUnifiedToolBar) is available in QtMacExtras. setUnifiedTitleAndToolBarOnMac(true); #endif rpcConsole = new RPCConsole(platformStyle, 0); helpMessageDialog = new HelpMessageDialog(this, false); #ifdef ENABLE_WALLET if(enableWallet) { /** Create wallet frame and make it the centralish widget */ walletFrame = new WalletFrame(platformStyle, this); //walletFrame = new WalletFrame(this); //setCentralWidget(walletFrame); walletFrame->setFixedWidth(850); walletFrame->setFixedHeight(390); walletFrame->move(0,165); } else #endif // ENABLE_WALLET { /* When compiled without wallet or -disablewallet is provided, * the central widget is the rpc console. */ setCentralWidget(rpcConsole); } // Accept D&D of URIs setAcceptDrops(true); // Header UI elements // logo - we'll make it a button that leads back to the overviewpage menu Logo = new QPushButton(this); Logo->move(20, 30); Logo->setFixedWidth(250); Logo->setFixedHeight(80); Logo->setObjectName("Logo"); connect(Logo, SIGNAL(clicked()), this, SLOT(gotoOverviewPage())); // balance frame bframe = new QFrame(this); bframe->move(290, 20); bframe->setFixedWidth(540); bframe->setFixedHeight(100); bframe->setObjectName("bframe"); // available balance label labelBalance = new QLabel(bframe); labelBalance->move(10, 25); labelBalance->setFixedWidth(520); labelBalance->setFixedHeight(20); labelBalance->setText("Available Balance:"); labelBalance->setObjectName("labelBalance"); // balance label labelHeaderBalance = new QLabel(bframe); labelHeaderBalance->move(10, 45); labelHeaderBalance->setFixedWidth(520); labelHeaderBalance->setFixedHeight(30); labelHeaderBalance->setText("0.00"); labelHeaderBalance->setObjectName("labelHeaderBalance"); // Create actions for the toolbar, menu bar and tray/dock icon // Needs walletFrame to be initialized createActions(); // Create application menu bar //createMenuBar(); // Create the toolbars createToolBars(); // Create system tray icon and notification createTrayIcon(networkStyle); // create bottom 'toolbar'... QWidget *toolbar2 = new QWidget(this); toolbar2->setFixedHeight(30); toolbar2->setFixedWidth(830); toolbar2->move(10, 620); toolbar2->setObjectName("toolbar2"); // ...add encryption, connections and blocks icons labelEncryptionIcon = new QLabel(toolbar2); labelEncryptionIcon->setObjectName("labelEncryptionIcon"); labelEncryptionIcon->setFixedHeight(20); labelEncryptionIcon->setFixedWidth(20); labelEncryptionIcon->move(80, 0); labelConnectionsIcon = new QLabel(toolbar2); labelConnectionsIcon->setPixmap(QIcon(":/icons/connect_0").pixmap(18, 18)); labelConnectionsIcon->setObjectName("labelConnectionsIcon"); labelConnectionsIcon->setFixedHeight(20); labelConnectionsIcon->setFixedWidth(20); labelConnectionsIcon->move(0, 0); labelBlocksIcon = new QLabel(toolbar2); labelBlocksIcon->setPixmap(QIcon(":/icons/connect0s").pixmap(18, 18)); //Initialize with 'searching' icon so people with slow connections see something labelBlocksIcon->setToolTip("Looking for more network connections"); labelBlocksIcon->setObjectName("labelBlocksIcon"); labelBlocksIcon->setFixedHeight(20); labelBlocksIcon->setFixedWidth(20); labelBlocksIcon->move(40, 0); QPushButton *aboutButton = new QPushButton(toolbar2); //aboutButton->setStyleSheet("padding: none; border: none; background-color: #232323; background-image: url(':/icons/about'); background-repeat: none; background-position: center;"); aboutButton->setFixedHeight(30); aboutButton->setFixedWidth(30); aboutButton->move(720, 0); aboutButton->setToolTip("About Bitcredit"); aboutButton->setObjectName("aboutButton"); connect(aboutButton, SIGNAL(clicked()), this, SLOT(aboutClicked())); QPushButton *hideButton = new QPushButton(toolbar2); //hideButton->setStyleSheet("padding: none; border: none; background-color: #232323; background-image: url(':/icons/hide'); background-repeat: none; background-position: center;"); hideButton->setFixedHeight(30); hideButton->setFixedWidth(30); hideButton->move(760, 0); hideButton->setToolTip("Minimise"); hideButton->setObjectName("hideButton"); connect(hideButton, SIGNAL(clicked()), this, SLOT(toggleHidden())); QPushButton *quitButton = new QPushButton(toolbar2); //quitButton->setStyleSheet("padding: none; border: none; background-color: #232323; background-image: url(':/icons/quit'); background-repeat: none; background-position: center;"); quitButton->setFixedHeight(30); quitButton->setFixedWidth(30); quitButton->move(800, 0); quitButton->setToolTip("Exit"); quitButton->setObjectName("quitButton"); connect(quitButton, SIGNAL(clicked()), qApp, SLOT(quit())); // Progress bar and label for blocks download (these will float if called since we haven't added them to anything else) progressBarLabel = new QLabel(); progressBarLabel->setVisible(false); progressBar = new GUIUtil::ProgressBar(); progressBar->setAlignment(Qt::AlignCenter); progressBar->setVisible(false); // Override style sheet for progress bar for styles that have a segmented progress bar, // as they make the text unreadable (workaround for issue #1071) // See https://qt-project.org/doc/qt-4.8/gallery.html QString curStyle = QApplication::style()->metaObject()->className(); if(curStyle == "QWindowsStyle" || curStyle == "QWindowsXPStyle") { progressBar->setStyleSheet("QProgressBar { background-color: #e8e8e8; border: 1px solid grey; border-radius: 7px; padding: 1px; text-align: center; } QProgressBar::chunk { background: QLinearGradient(x1: 0, y1: 0, x2: 1, y2: 0, stop: 0 #FF8000, stop: 1 orange); border-radius: 7px; margin: 0px; }"); } // Install event filter to be able to catch status tip events (QEvent::StatusTip) this->installEventFilter(this); // Initially wallet actions should be disabled setWalletActionsEnabled(false); // Subscribe to notifications from core subscribeToCoreSignals(); }