void CGTabPage::addComponent(QString name, QString prop, QString var, quint16 x, quint16 y, quint16 w, quint16 h) { //RPGComponent *comp; QLineEdit *tb; QCheckBox *cb; // If comp's property value is empty, then it is a checkbox, otherwise textbox. if(prop.isEmpty()) { //comp = new RGCheckBox(panel, page(), QPoint(x, y), QPoint(w, h)); cb = new QCheckBox(this); cb->move(x, y); cb->resize(w, h); } else { //comp = new RGTextBox(panel, page(), QPoint(x, y), QPoint(w, h)); tb = new QLineEdit(this); tb->move(x, y); tb->resize(w, h); // Add Text to TextBox //RGTextBox *tb = (RGTextBox *)comp; if(var.isEmpty()) // Is it a character trait? tb->setText(name + ":" + prop); else tb->setText(name + ":" + var + ":" + prop); tb->show(); } /* comp->setDataName(name); comp->setDataProperty(prop); comp->setDataVariable(var); components.append(comp); RPGRulebook::Instance()->addComponent(comp); */ }
int main(int argc, char *argv[]) { QApplication app(argc, argv); QWidget window; QLabel *label = new QLabel(QApplication::translate("windowlayout", "Scale:"),&window); QCheckBox *chb = new QCheckBox(QApplication::translate("windowlayout", "Calc mode"),&window); mle *myline = new mle(&window); render widget(&window); QPainter painter; QSlider *spinbox = new QSlider(Qt::Horizontal,&window); spinbox->setValue(30); widget.setGeometry(10,10, 512, 512); myline->setGeometry(10,532,512,20); myline->setText("Enter expession"); myline->createStandardContextMenu(); myline->selectAll(); label->setGeometry(532,10,200,20); chb->move(532,535); spinbox->setGeometry(567,10,165,20); spinbox->setRange(1, 200); //Святое место определения механизма сигналов и слотов, унёсший 8 дней практики на реализацию передачи значений между экземплярами класса //изменять с осторожностью и благословлением, церковная зона QObject::connect(spinbox, SIGNAL(valueChanged(int)), &widget, SLOT(scale(int))); QObject::connect(spinbox, SIGNAL(valueChanged(int)), myline, SLOT(emitsig())); QObject::connect(myline, SIGNAL(returnPressed()), myline, SLOT(emitsig())); QObject::connect(myline, SIGNAL(givechar(QString)), &widget, SLOT(calc(QString))); QObject::connect(chb, SIGNAL(stateChanged(int)), &widget, SLOT(chk(int))); QObject::connect(&widget, SIGNAL(emitstr(QString)), myline, SLOT(takestr(QString))); //конец защищенной церковной зоны window.setWindowTitle( QApplication::translate("GCPLOT", "GCPLOT")); window.setFixedSize(742, 562); window.show(); return app.exec(); }
WidgetParameterBool::WidgetParameterBool(ParameterPtrT<bool> parameter) : WidgetParameter<bool>(parameter) { QCheckBox* checkBox = new QCheckBox(this); checkBox->setChecked(parameter->lastValue()); checkBox->move(0,0); parameter->addNewInternalValueCallback([checkBox, this](bool value){ checkBox->blockSignals(true); checkBox->setChecked(value); checkBox->blockSignals(false); }); BOOST_VERIFY(connect(checkBox, SELECT<bool>::OVERLOAD_OF(&QCheckBox::clicked), [this](bool b) { mParameter->set(b); })); mWidget = checkBox; }
/* class QSlotStorage : public QObject { public: QSlotStorage() { } void onClick() { printf("QSlotStorage::onClicked()\n"); fflush(stdout); } }; */ int main() { BApplication *app = new BApplication("application/x.vnd-Lemon-Nirvana"); TestWindow *test = new TestWindow( BRect(30,30,700,500), "test1" ); QWidget *widget = test->RootWidget(); QCheckBox *check = new QCheckBox( widget ); check->resize(100,200); QSlotStorage *storage = new QSlotStorage(); QObject::connect(check, SIGNAL(clicked()), new QSlot(storage, SLOT(onClick()))); KWQSignal *signal = check->findSignal(SIGNAL(clicked())); //printf("%s\n",signal->_name); signal->call(); check->setText("Label sd fsd fsd fsd fsd fsd fsd fsd fsd fsd fsd fsd fs dfs df sd fsd fs fd"); check->move(100,100); test->Show(); app->Run(); return 0; }
CupcakeWar::CupcakeWar(QWidget* parent) : ConfigWindowBase(parent), nutritions({"Grape", "Kiwi", "Orange", "Pineapple", "Raspberry", "Straberry"}), other_attr_val(4, 0) { add_level(); for (int i = 0; i < (int)nutritions.size(); ++i) { QCheckBox* qcb = new QCheckBox(nutritions[i], this); QLineEdit* txt = new QLineEdit(this); qcb->move(400, 100 + i * 40); txt->move(500, 100 + i * 40); selection.push_back(std::make_pair(qcb, txt)); txt->setValidator(validator); connect(qcb, SIGNAL(clicked()), this, SLOT(SetVal())); connect(qcb, SIGNAL(clicked()), this, SLOT(CheckEmpty())); connect(txt, SIGNAL(editingFinished()), this, SLOT(SetVal())); connect(txt, SIGNAL(textEdited(QString)), this, SLOT(CheckEmpty())); } for(int i = 0; i < 4; ++i) { QLineEdit* txt = new QLineEdit(this); txt->move(200, 100 + i * 40); QLabel *name = new QLabel(i == 0 ? "flour amount" : i == 1 ? "milk amount" : i == 2 ? "max" : "min", this); name->move(100, 100 + i * 40); other_attr.push_back(txt); connect(txt, SIGNAL(editingFinished()), this, SLOT(SetVal())); } grade = new QComboBox(this); QLabel *name = new QLabel("grade", this); name->move(100, 100 + 4 * 40); grade->move(200, 100 + 4 * 40); grade->addItems({"3", "4", "5", "6", "7", "8"}); // connect(list_view, SIGNAL(level_added()), this, SLOT(add_level())); // connect(list_view->selectionModel(), SIGNAL(currentChanged(QModelIndex,QModelIndex)), this, SLOT(Update(QModelIndex))); }
void ServiceItemDelegate::updateItemWidgets(const QList<QWidget*> widgets, const QStyleOptionViewItem& option, const QPersistentModelIndex& index) const { QCheckBox* checkBox = static_cast<QCheckBox*>(widgets[0]); KPushButton *configureButton = static_cast<KPushButton*>(widgets[1]); const int itemHeight = sizeHint(option, index).height(); // Update the checkbox showing the service name and icon const QAbstractItemModel* model = index.model(); checkBox->setText(model->data(index).toString()); const QString iconName = model->data(index, Qt::DecorationRole).toString(); if (!iconName.isEmpty()) { checkBox->setIcon(KIcon(iconName)); } checkBox->setChecked(model->data(index, Qt::CheckStateRole).toBool()); const bool configurable = model->data(index, ServiceModel::ConfigurableRole).toBool(); int checkBoxWidth = option.rect.width(); if (configurable) { checkBoxWidth -= configureButton->sizeHint().width(); } checkBox->resize(checkBoxWidth, checkBox->sizeHint().height()); checkBox->move(0, (itemHeight - checkBox->height()) / 2); // Update the configuration button if (configurable) { configureButton->setEnabled(checkBox->isChecked()); configureButton->setIcon(KIcon("configure")); configureButton->resize(configureButton->sizeHint()); configureButton->move(option.rect.right() - configureButton->width(), (itemHeight - configureButton->height()) / 2); } configureButton->setVisible(configurable); }
void AccountsListDelegate::updateItemWidgets(const QList<QWidget *> widgets, const QStyleOptionViewItem &option, const QPersistentModelIndex &index) const { // draws: // AccountName // Checkbox | Icon | | ConnectionIcon | ConnectionState // errorMessage if (!index.isValid()) { return; } Q_ASSERT(widgets.size() == 6); // Get the widgets QCheckBox* checkbox = qobject_cast<QCheckBox*>(widgets.at(0)); ChangeIconButton* changeIconButton = qobject_cast<ChangeIconButton*>(widgets.at(1)); QLabel *statusTextLabel = qobject_cast<QLabel*>(widgets.at(2)); QLabel *statusIconLabel = qobject_cast<QLabel*>(widgets.at(3)); EditDisplayNameButton *displayNameButton = qobject_cast<EditDisplayNameButton*>(widgets.at(4)); QLabel *connectionErrorLabel = qobject_cast<QLabel*>(widgets.at(5)); Q_ASSERT(checkbox); Q_ASSERT(changeIconButton); Q_ASSERT(statusTextLabel); Q_ASSERT(statusIconLabel); Q_ASSERT(displayNameButton); Q_ASSERT(connectionErrorLabel); bool isSelected(itemView()->selectionModel()->isSelected(index) && itemView()->hasFocus()); bool isEnabled(index.data(KTp::AccountsListModel::EnabledRole).toBool()); KIcon accountIcon(index.data(Qt::DecorationRole).value<QIcon>()); KIcon statusIcon(index.data(KTp::AccountsListModel::ConnectionStateIconRole).value<QIcon>()); QString statusText(index.data(KTp::AccountsListModel::ConnectionStateDisplayRole).toString()); QString displayName(index.data(Qt::DisplayRole).toString()); QString connectionError(index.data(KTp::AccountsListModel::ConnectionErrorMessageDisplayRole).toString()); Tp::AccountPtr account(index.data(KTp::AccountsListModel::AccountRole).value<Tp::AccountPtr>()); if (!account->isEnabled()) { connectionError = i18n("Click checkbox to enable"); } QRect outerRect(0, 0, option.rect.width(), option.rect.height()); QRect contentRect = outerRect.adjusted(m_hpadding,m_vpadding,-m_hpadding,-m_vpadding); //add some padding // checkbox if (isEnabled) { checkbox->setChecked(true);; checkbox->setToolTip(i18n("Disable account")); } else { checkbox->setChecked(false); checkbox->setToolTip(i18n("Enable account")); } int checkboxLeftMargin = contentRect.left(); int checkboxTopMargin = (outerRect.height() - checkbox->height()) / 2; checkbox->move(checkboxLeftMargin, checkboxTopMargin); // changeIconButton changeIconButton->setIcon(accountIcon); changeIconButton->setAccount(account); // At the moment (KDE 4.8.1) decorationSize is not passed from KWidgetItemDelegate // through the QStyleOptionViewItem, therefore we leave default size unless // the user has a more recent version. if (option.decorationSize.width() > -1) { changeIconButton->setButtonIconSize(option.decorationSize.width()); } int changeIconButtonLeftMargin = checkboxLeftMargin + checkbox->width(); int changeIconButtonTopMargin = (outerRect.height() - changeIconButton->height()) / 2; changeIconButton->move(changeIconButtonLeftMargin, changeIconButtonTopMargin); // statusTextLabel QFont statusTextFont = option.font; QPalette statusTextLabelPalette = option.palette; if (isEnabled) { statusTextLabel->setEnabled(true); statusTextFont.setItalic(false); } else { statusTextLabel->setDisabled(true); statusTextFont.setItalic(true); } if (isSelected) { statusTextLabelPalette.setColor(QPalette::Text, statusTextLabelPalette.color(QPalette::Active, QPalette::HighlightedText)); } statusTextLabel->setPalette(statusTextLabelPalette); statusTextLabel->setFont(statusTextFont); statusTextLabel->setText(statusText); statusTextLabel->setFixedSize(statusTextLabel->fontMetrics().boundingRect(statusText).width(), statusTextLabel->height()); int statusTextLabelLeftMargin = contentRect.right() - statusTextLabel->width(); int statusTextLabelTopMargin = (outerRect.height() - statusTextLabel->height()) / 2; statusTextLabel->move(statusTextLabelLeftMargin, statusTextLabelTopMargin); // statusIconLabel statusIconLabel->setPixmap(statusIcon.pixmap(KIconLoader::SizeSmall)); statusIconLabel->setFixedSize(statusIconLabel->minimumSizeHint()); int statusIconLabelLeftMargin = contentRect.right() - statusTextLabel->width() - statusIconLabel->width() - 6; int statusIconLabelTopMargin = (outerRect.height() - statusIconLabel->height()) / 2; statusIconLabel->move(statusIconLabelLeftMargin, statusIconLabelTopMargin); QRect innerRect = contentRect.adjusted(changeIconButton->geometry().right() - contentRect.left(), 0, -statusTextLabel->width() - statusIconLabel->width() - 6, 0); // rect containing account name and error message // displayNameButton QFont displayNameButtonFont = option.font; QPalette displayNameButtonPalette = option.palette; if (isEnabled) { displayNameButtonPalette.setColor(QPalette::WindowText, displayNameButtonPalette.color(QPalette::Active, QPalette::Text)); displayNameButtonFont.setBold(true); } else { displayNameButtonFont.setItalic(true); // NOTE: Flat QPushButton use WindowText instead of ButtonText for button text color displayNameButtonPalette.setColor(QPalette::WindowText, displayNameButtonPalette.color(QPalette::Disabled, QPalette::Text)); } if (isSelected) { // Account is selected displayNameButtonPalette.setColor(QPalette::WindowText, displayNameButtonPalette.color(QPalette::Active, QPalette::HighlightedText)); } displayNameButton->setFont(displayNameButtonFont); displayNameButton->setPalette(displayNameButtonPalette); QString displayNameButtonText = displayNameButton->fontMetrics().elidedText(displayName, Qt::ElideRight, innerRect.width() - (m_hpadding*2)); displayNameButton->setText(displayNameButtonText); displayNameButton->setFixedSize(displayNameButton->fontMetrics().boundingRect(displayNameButtonText).width() + (m_hpadding*2), displayNameButton->minimumSizeHint().height()); displayNameButton->setAccount(account); int displayNameButtonLeftMargin = innerRect.left(); int displayNameButtonTopMargin = innerRect.top(); displayNameButton->move(displayNameButtonLeftMargin, displayNameButtonTopMargin); // connectionErrorLabel QFont connectionErrorLabelFont = option.font; QPalette connectionErrorLabelPalette = option.palette; if (isEnabled) { connectionErrorLabelPalette.setColor(QPalette::WindowText, connectionErrorLabelPalette.color(QPalette::Active, QPalette::Text)); } else { connectionErrorLabelFont.setItalic(true); connectionErrorLabelPalette.setColor(QPalette::Text, connectionErrorLabelPalette.color(QPalette::Disabled, QPalette::Text)); } if (isSelected) { // Account is selected connectionErrorLabelPalette.setColor(QPalette::Text, connectionErrorLabelPalette.color(QPalette::Active, QPalette::HighlightedText)); } connectionErrorLabel->setFont(connectionErrorLabelFont); connectionErrorLabel->setPalette(connectionErrorLabelPalette); QString connectionErrorLabelText = connectionErrorLabel->fontMetrics().elidedText(connectionError, Qt::ElideRight, innerRect.width() - (m_hpadding*2)); connectionErrorLabel->setText(connectionErrorLabelText); connectionErrorLabel->setFixedSize(connectionErrorLabel->fontMetrics().boundingRect(connectionErrorLabelText).width(), displayNameButton->height()); int connectionErrorLabelLeftMargin = innerRect.left() + m_hpadding; int connectionErrorLabelTopMargin = contentRect.bottom() - displayNameButton->height(); connectionErrorLabel->move(connectionErrorLabelLeftMargin, connectionErrorLabelTopMargin); }
Piano::Piano(QWidget *parent) : QWidget(parent) { init_log(); QPalette Pal(palette()); Pal.setColor(QPalette::Background, QColor::fromRgb(240, 240, 240)); setAutoFillBackground(true); setPalette(Pal); showing = false; //displaying the scorebox b_names_dip = false; b_racc_disp = false; notes = new QVector<Touche*>(); notes_jouees = new QVector<QString>(); setFixedSize(800, 310); QPushButton *raccButt= new QPushButton(QString(""),this); raccButt->setToolTip(QString("Affiche les raccourcis clavier pour le piano")); QPushButton *noteNames = new QPushButton(QString(""),this); noteNames->setToolTip(QString("Affiche le nom des notes sur le piano")); QCheckBox *checkB = new QCheckBox(QString("options affichage"),this); checkB->setToolTip(QString("Affiche/cache les options d'affiche du piano")); QPushButton *retour = new QPushButton(QString(""),this); checkB->setChecked(true); retour->move(740,0); retour->setStyleSheet("border-image: url(:/new/prefix1/undo.png)"); retour->setToolTip(QString("Annule la dernière note jouée")); retour->resize(50,50); QPushButton *solution = new QPushButton(QString("Solution"),this); solution->setToolTip(QString("Aide: Indique la note suivante sur le piano")); solution->move(0,10); checkB->move(0,282); Touche* doM = new Touche(this, QString("tab"),QString("Do")); int sizeT= 38;//doM->width(); //QMessageBox::information(new QWidget(),QString("taille "),QString::number(sizeT)); int hauteur = 100; int nT =3; raccButt->move(0,hauteur+50); raccButt->setFixedSize(140,50); raccButt->setStyleSheet("border-image: url(:/img/clavier.svg.png);" ); noteNames->move(660,hauteur +50); noteNames->setFixedSize(140,50); noteNames->setStyleSheet("border-image: url(:/img/doremi);" "border-width: 2px;"); doM->move(sizeT*nT,hauteur); nT+=1; Touche* reM = new Touche(this, QString("A"),QString("Ré")); reM->move(sizeT*nT,hauteur); nT+=1; Touche* miM = new Touche(this, QString("Z"),QString("Mi")); miM->move(sizeT*nT,hauteur); nT+=1; Touche* faM = new Touche(this, QString("E"),QString("Fa")); faM->move(sizeT*nT,hauteur); nT+=1; Touche* solM = new Touche(this, QString("R"),QString("Sol")); solM->move(sizeT*nT,hauteur); nT+=1; Touche* laM = new Touche(this, QString("T"),QString("La")); laM->move(sizeT*nT,hauteur); nT+=1; Touche* siM = new Touche(this, QString("Y"),QString("si")); siM->move(sizeT*nT,hauteur); nT+=1; Touche* dom = new Touche(this, QString("U"),QString("Do")); dom->move(sizeT*nT,hauteur); nT+=1; Touche* rem = new Touche(this, QString("I"),QString("Ré")); rem->move(sizeT*nT,hauteur); nT+=1; Touche* mim = new Touche(this, QString("O"),QString("Mi")); mim->move(sizeT*nT,hauteur); nT+=1; Touche* fam = new Touche(this, QString("P"),QString("Fa")); fam->move(sizeT*nT,hauteur); nT+=1; Touche* solm = new Touche(this, QString(/*"dead_circumflex"*/"16781906"),QString("Sol")); solm->move(sizeT*nT,hauteur); nT+=1; Touche* lam = new Touche(this, QString("$"),QString("La")); lam->move(sizeT*nT,hauteur); nT+=1; Touche* sim = new Touche(this, QString("Return"),QString("si")); sim->move(sizeT*nT,hauteur); nT=4; Touche* doMD = new Touche(this, QString("&"),QString("Do#")); doMD->black(); doMD->move(sizeT*nT-sizeT/4,hauteur); nT+=1; Touche* reMD = new Touche(this, QString("é"),QString("Ré#")); reMD->black(); reMD->move(sizeT*nT-sizeT/4,hauteur); nT+=2; Touche* faMD = new Touche(this, QString("'"),QString("Fa#")); faMD->black(); faMD->move(sizeT*nT-sizeT/4,hauteur); nT+=1; Touche* solMD = new Touche(this, QString("("),QString("Sol#")); solMD->black(); solMD->move(sizeT*nT-sizeT/4,hauteur); nT+=1; Touche* laMD = new Touche(this, QString("-"),QString("La#")); laMD->black(); laMD->move(sizeT*nT-sizeT/4,hauteur); nT+=2; Touche* domD = new Touche(this, QString("_"),QString("Do#")); domD->black(); domD->move(sizeT*nT-sizeT/4,hauteur); nT+=1; Touche* remD = new Touche(this, QString("ç"),QString("Ré#")); remD->black(); remD->move(sizeT*nT-sizeT/4,hauteur); nT+=2; Touche* famD = new Touche(this, QString(")"),QString("Fa#")); famD->black(); famD->move(sizeT*nT-sizeT/4,hauteur); nT+=1; Touche* solmD = new Touche(this, QString("="),QString("Sol#")); solmD->black(); solmD->move(sizeT*nT-sizeT/4,hauteur); nT+=1; Touche* lamD = new Touche(this, QString("Backspace"),QString("La#")); lamD->black(); lamD->move(sizeT*nT-sizeT/4,hauteur); QObject::connect(doM, SIGNAL(clicked()), this, SLOT(play_doM()));notes->append(doM); QObject::connect(reM, SIGNAL(clicked()), this, SLOT(play_reM()));notes->append(reM); QObject::connect(miM, SIGNAL(clicked()), this, SLOT(play_miM()));notes->append(miM); QObject::connect(faM, SIGNAL(clicked()), this, SLOT(play_faM()));notes->append(faM); QObject::connect(solM, SIGNAL(clicked()), this, SLOT(play_solM()));notes->append(solM); QObject::connect(laM, SIGNAL(clicked()), this, SLOT(play_laM()));notes->append(laM); QObject::connect(siM, SIGNAL(clicked()), this, SLOT(play_siM()));notes->append(siM); QObject::connect(dom, SIGNAL(clicked()), this, SLOT(play_dom()));notes->append(dom); QObject::connect(rem, SIGNAL(clicked()), this, SLOT(play_rem()));notes->append(rem); QObject::connect(mim, SIGNAL(clicked()), this, SLOT(play_mim()));notes->append(mim); QObject::connect(fam, SIGNAL(clicked()), this, SLOT(play_fam()));notes->append(fam); QObject::connect(solm, SIGNAL(clicked()), this, SLOT(play_solm()));notes->append(solm); QObject::connect(lam, SIGNAL(clicked()), this, SLOT(play_lam()));notes->append(lam); QObject::connect(sim, SIGNAL(clicked()), this, SLOT(play_sim()));notes->append(sim); QObject::connect(doMD, SIGNAL(clicked()), this, SLOT(play_doMD()));notes->append(doMD); QObject::connect(reMD, SIGNAL(clicked()), this, SLOT(play_reMD()));notes->append(reMD); QObject::connect(faMD, SIGNAL(clicked()), this, SLOT(play_faMD()));notes->append(faMD); QObject::connect(solMD, SIGNAL(clicked()), this, SLOT(play_solMD()));notes->append(solMD); QObject::connect(laMD, SIGNAL(clicked()), this, SLOT(play_laMD()));notes->append(laMD); QObject::connect(domD, SIGNAL(clicked()), this, SLOT(play_domD()));notes->append(domD); QObject::connect(remD, SIGNAL(clicked()), this, SLOT(play_remD()));notes->append(remD); QObject::connect(famD, SIGNAL(clicked()), this, SLOT(play_famD()));notes->append(famD); QObject::connect(solmD, SIGNAL(clicked()), this, SLOT(play_solmD()));notes->append(solmD); QObject::connect(lamD, SIGNAL(clicked()), this, SLOT(play_lamD()));notes->append(lamD); QObject::connect(raccButt, SIGNAL(clicked()), this, SLOT(display_racc())); QObject::connect(noteNames, SIGNAL(clicked()), this, SLOT(display_names())); QObject::connect(checkB, SIGNAL(toggled(bool)), this, SLOT(checking(bool))); QObject::connect(retour, SIGNAL(clicked()), this, SLOT(retour_arriere())); }