Esempio n. 1
0
void Single_Player::Create()
{
    QPixmap pixmap1("Black_Circle");
    QPixmap pixmap2("white-circle");
    QIcon Icon1(pixmap1);
    QIcon Icon2(pixmap2);
    for(int i=0;i<8;i++)
     for(int j=0;j<8;j++)
     {
         array[i][j]=0;
         button[i][j].setParent(this);
         button[i][j].resize(30,30);
         button[i][j].setStyleSheet("background-color:grey");
         button[i][j].move(30*j+10+30,30*i+10);
         button[i][j].show();
     }
    array[3][3]=White;
    array[3][4]=Black;
    array[4][4]=White;
    array[4][3]=Black;
    for(int i=0;i<8;i++)
     for(int j=0;j<8;j++)
     {
         if(array[i][j]==Black)
         {
             button[i][j].setIcon(Icon1);
             button[i][j].setIconSize(QSize(20,20));
         }
         if(array[i][j]==White)
        {
             button[i][j].setIcon(Icon2);
             button[i][j].setIconSize(QSize(20,20));
        }
     }
}
Esempio n. 2
0
LineEdit::LineEdit(QWidget *parent)
  : QLineEdit(parent)
{
  searchButton = new QToolButton(this);
  QPixmap pixmap1(":/lineeditimages/search.png");
  searchButton->setIcon(QIcon(pixmap1));
  searchButton->setIconSize(pixmap1.size());
  searchButton->setCursor(Qt::ArrowCursor);
  searchButton->setStyleSheet("QToolButton { border: none; padding: 0px; }");
  clearButton = new QToolButton(this);
  QPixmap pixmap2(":/lineeditimages/clear_left.png");
  clearButton->setIcon(QIcon(pixmap2));
  clearButton->setIconSize(pixmap2.size());
  clearButton->setCursor(Qt::ArrowCursor);
  clearButton->setStyleSheet("QToolButton { border: none; padding: 0px; }");
  clearButton->setToolTip(tr("Clear the text"));
  clearButton->hide();
  connect(clearButton, SIGNAL(clicked()), this, SLOT(clear()));
  connect(this, SIGNAL(textChanged(const QString&)), this, SLOT(updateCloseButton(const QString&)));
  int frameWidth = style()->pixelMetric(QStyle::PM_DefaultFrameWidth);
  setStyleSheet(QString("QLineEdit { padding-right: %1px; padding-left: %2px; border-radius: 10px; }").arg(clearButton->sizeHint().width() + frameWidth + 1).arg(clearButton->sizeHint().width() + frameWidth + 1));
#ifdef Q_WS_MAC
  setAttribute(Qt::WA_MacShowFocusRect, 0);
#endif
  QSize msz = minimumSizeHint();
  setMinimumSize(qMax(msz.width(), clearButton->sizeHint().width() + searchButton->sizeHint().width() + frameWidth * 2 + 2),
                 qMax(msz.height(), clearButton->sizeHint().height() + frameWidth * 2 + 2));
}
Esempio n. 3
0
/**
 * Constructor that sets the first screen, "welcome" screen.
 *
 * @param *parent Pointer to the QWidget
 *
 */
MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
    ui->setupUi(this);
    this->setStyleSheet(
                "QPushButton#pushButton_2 {"
                "background-color: rgb(125,125,175);"
                "border-style: outset;"
                "border-width: 2px;"
                "border-color: rgb(50,50,75);"
                "font: bold 22px;"
                "border-radius: 5px;"
                "min-width: 7em;}"

                "QPushButton#pushButton_2:hover:pressed {"
                "background-color: rgb(100,100,145);"
                "border-style:inset;}"

                "QPushButton#pushButton_2:hover {"
                "background-color: rgb(130,130,180);}"

                "QGraphicsView#graphicsView_2 {"
                "border-style: inset;"
                "border-width: 2px;"
                "border-radius: 5px;"
                "border-color: rgb(150,150,175); }"

                "QGraphicsView#graphicsView {"
                "border: transparent;}"

                "QGraphicsView#graphicsView_3 {"
                "border-style: inset;"
                "border-width: 2px;"
                "border-radius: 5px;"
                "border-color: rgb(150,150,175); }"


                );



    //set the screen switching to get out of welcome screen
    connect(ui->pushButton_2, SIGNAL(clicked()), SLOT(hide()));
    connect(ui->pushButton_2, SIGNAL(clicked()), SIGNAL(showOtherWindow()));

    //insert the logo image on the welcome screen
    std :: string backgroundImage = "ombi-logo2.png";
    QPixmap pixmap1(backgroundImage.c_str());
    QRect rect = ui->graphicsView->rect();
    QSize sizeLogo(rect.width() , rect.height());
    QPixmap pixmap(pixmap1.scaled(sizeLogo));
    QGraphicsScene* scene = new QGraphicsScene(this);
    scene->addPixmap(pixmap);
    ui->graphicsView->setScene(scene);



}
Esempio n. 4
0
File: main.cpp Progetto: ifhw/study
int main(int argc, char *argv[])
{
    QApplication app(argc, argv);

    // 创建标准项模型
    QStandardItemModel model;
    // 获取模型的根项(Root Item),根项是不可见的
    QStandardItem *parentItem = model.invisibleRootItem();

    // 创建标准项item0,并设置显示文本,图标和工具提示
    QStandardItem *item0 = new QStandardItem;
    item0->setText("A");
    QPixmap pixmap0(50,50);
    pixmap0.fill("red");
    item0->setIcon(QIcon(pixmap0));
    item0->setToolTip("indexA");
    // 将创建的标准项作为根项的子项
    parentItem->appendRow(item0);
    // 将创建的标准项作为新的父项
    parentItem = item0;

    // 创建新的标准项,它将作为item0的子项
    QStandardItem *item1 = new QStandardItem;
    item1->setText("B");
    QPixmap pixmap1(50,50);
    pixmap1.fill("blue");
    item1->setIcon(QIcon(pixmap1));
    item1->setToolTip("indexB");
    parentItem->appendRow(item1);

    // 创建新的标准项,这里使用了另一种方法来设置文本、图标和工具提示
    QStandardItem *item2 = new QStandardItem;
    QPixmap pixmap2(50,50);
    pixmap2.fill("green");
    item2->setData("C", Qt::EditRole);
    item2->setData("indexC", Qt::ToolTipRole);
    item2->setData(QIcon(pixmap2), Qt::DecorationRole);
    parentItem->appendRow(item2);

    // 在树视图中显示模型
    QTreeView view;
    view.setModel(&model);
    view.show();

    // 获取item0的索引并输出item0的子项数目,然后输出了item1的显示文本和工具提示
    QModelIndex indexA = model.index(0, 0, QModelIndex());
    qDebug() << "indexA row count: " << model.rowCount(indexA);
    QModelIndex indexB = model.index(0, 0, indexA);
    qDebug() << "indexB text: " << model.data(indexB, Qt::EditRole).toString();
    qDebug() << "indexB toolTip: " << model.data(indexB, Qt::ToolTipRole).toString();

    return app.exec();
}
Dialog_1::Dialog_1(QWidget *parent) :
    QDialog(parent),
    ui(new Ui::Dialog_1)
{
    ui->setupUi(this);
    this->setWindowFlags(Qt::FramelessWindowHint);
    this->setGeometry(250,50,500,700);
    ui->label->setGeometry(60,30,387.5,652.5);
    QPixmap pixmap1("/tmp/ass/screenshot.png");
    QPixmap pixmap(pixmap1.scaled(387.5,652.5, Qt::KeepAspectRatio));
    ui->label->setPixmap(pixmap);
    ui->label->setStyleSheet("background-image : url(:/img/pics/nobg.png)");
}
Esempio n. 6
0
void PatientSearchForm::setBackgroundImage()
{	
	//Using QPalette you can set background image as follows.
	QPalette p = palette();
	//Load image to QPixmap, Give full path of image
	QPixmap pixmap1(":/icons/background.png"); //For emulator C: is ..\epoc32\winscw\c so image must be at that location
/*
	//resize image if it is larger than screen size.
	QDesktopWidget* desktopWidget = QApplication::desktop();
	QRect rect = desktopWidget->availableGeometry();

	QSize size(rect.width() , rect.height());
	//resize as per your reqirement..
	//QPixmap pixmap(pixmap1.scaled(size));
	//QPixmap pixmap(pixmap1.scaledToWidth(rect.height()));*/
	p.setBrush(QPalette::Background,  pixmap1);
	setPalette(p);
}
Esempio n. 7
0
void LabelWidget::setBackgroundImage()
{

    //Using QPalette you can set background image as follows.
    QPalette p = palette();
    //Load image to QPixmap, Give full path of image
    QPixmap pixmap1(":/icons/searchLabelBg.png"); //For emulator C: is ..\epoc32\winscw\c so image must be at that location

    //resize image if it is larger than screen size.
    //QDesktopWidget* desktopWidget = QApplication::desktop();
    //QRect rect = desktopWidget->availableGeometry();
    QRect rect = this->geometry();
    QSize size(rect.width(), rect.height());
    //resize as per your reqirement..
    //QPixmap pixmap(pixmap1.scaled(size, Qt::KeepAspectRatioByExpanding));
    p.setBrush(QPalette::Background,  pixmap1);
    setPalette(p);
}
Esempio n. 8
0
int main(int argc, char **argv) {
  QApplication app(argc, argv);

  QStandardItemModel model;
  QStandardItem *parentItem = model.invisibleRootItem();

  QStandardItem *item0 = new QStandardItem;
  item0->setText("A");
  QPixmap pixmap0(50, 50);
  pixmap0.fill("red");
  item0->setIcon(QIcon(pixmap0));
  item0->setToolTip("indexA");
  parentItem->appendRow(item0);

  parentItem = item0;
  QStandardItem *item1 = new QStandardItem;
  item1->setText("B");
  QPixmap pixmap1(50, 50);
  pixmap1.fill("blue");
  item1->setIcon(QIcon(pixmap1));
  item1->setToolTip("indexB");
  parentItem->appendRow(item1);

  QStandardItem *item2 = new QStandardItem;
  QPixmap pixmap2(50, 50);
  pixmap2.fill("green");
  item2->setData("C", Qt::EditRole);
  item2->setData("indexC", Qt::ToolTipRole);
  item2->setData(QIcon(pixmap2), Qt::DecorationRole);
  parentItem->appendRow(item2);

  QTreeView view;
  view.setModel(&model);
  view.show();

  QModelIndex indexA = model.index(0, 0, QModelIndex());
  qDebug() << "indexA row count: " << model.rowCount(indexA);
  QModelIndex indexB = model.index(0, 0, indexA);
  qDebug() << "indexB text: " << model.data(indexB, Qt::EditRole).toString();
  qDebug() << "indexB toolTip: " << model.data(indexB, Qt::ToolTipRole)
                                        .toString();

  return app.exec();
}
Esempio n. 9
0
Principal::Principal(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::Principal)
{
    ui->setupUi(this);
    r = -1;
    QPixmap pixmap1("icon/add.png");
    QPixmap pixmap2("icon/conf.png");
    QPixmap pixmap3("icon/del.png");
    QPixmap pixmap4("icon/Sair.png");
    QPixmap pixmap5("icon/pasta.png");
    QPixmap pixmap6("icon/detalhe.png");
    QIcon ButtonIcon(pixmap1);
    QIcon ButtonIcon1(pixmap2);
    QIcon ButtonIcon2(pixmap3);
    QIcon ButtonIcon3(pixmap4);
    QIcon ButtonIcon4(pixmap5);
    QIcon ButtonIcon5(pixmap6);
    ui->add_3->setIcon(ButtonIcon);
    ui->add_3->setIconSize(pixmap1.rect().size());
    ui->add_3->setStyleSheet(styleSheet().append(QString("border-image:url(icon/1.png);")));
    ui->alterar->setIcon(ButtonIcon1);
    ui->alterar->setIconSize(pixmap1.rect().size());
    ui->alterar->setStyleSheet(styleSheet().append(QString("border-image:url(icon/1.png);")));
    ui->deletar->setIcon(ButtonIcon2);
    ui->deletar->setIconSize(pixmap1.rect().size());
    ui->deletar->setStyleSheet(styleSheet().append(QString("border-image:url(icon/1.png);")));
    ui->sair->setIcon(ButtonIcon3);
    ui->sair->setIconSize(pixmap1.rect().size());
    ui->sair->setStyleSheet(styleSheet().append(QString("border-image:url(icon/1.png);")));
    ui->pasta->setIcon(ButtonIcon4);
    ui->pasta->setIconSize(pixmap1.rect().size());
    ui->pasta->setStyleSheet(styleSheet().append(QString("border-image:url(icon/1.png);")));
    AnimeDao a;
    if(a.getStatus() == true){
        ui->statusBar->showMessage("Quantidade de Animes Cadastrados: "+QString::number(a.getLista().length()));
    }
    preencheTabela(a.getLista());
    QPixmap pixmap9("icon/icon.png");
    this->setWindowIcon(pixmap9);

}
Esempio n. 10
0
//This function clears the buttons's background and set them again
void Single_Player::Modify()
{
    QPixmap pixmap("None");
    QIcon icon(pixmap);
    for(int i=0;i<8;i++)
     for(int j=0;j<8;j++)
     {
         if(array[i][j]!=White && array[i][j]!=Black)
         {
         button[i][j].setIcon(icon);
         button[i][j].setIconSize(QSize(20,20));
     }
 }
    if(turn==white)
        ui->label->setText("White");
    if(turn==black)
        ui->label->setText("Black");
      QPixmap pixmap1("Black_Circle");
      QPixmap pixmap2("white-circle");
      QIcon Icon1(pixmap1);
      QIcon Icon2(pixmap2);
      for(int i=0;i<=7;i++)
          for(int j=0;j<=7;j++)
          {
              if(array[i][j]==Black)
           {
                  button[i][j].setIcon(Icon1);
                  button[i][j].setIconSize(QSize(20,20));
              }
              if(array[i][j]==White)
              {
                  button[i][j].setIcon(Icon2);
                  button[i][j].setIconSize(QSize(20,20));
              }
          }
      }
listMemberDialog::listMemberDialog(QWidget *parent,QString classId)
{
	conn = database::connectByC();
	QVBoxLayout *topLeftLayout = new QVBoxLayout;

	view  = new QTableView(this);
	model = new QStandardItemModel(this);
	view->setModel(model);

	model->setHorizontalHeaderItem(0, new QStandardItem(tr("ID")));
	model->setHorizontalHeaderItem(1, new QStandardItem(tr("Name")));
	model->setHorizontalHeaderItem(2, new QStandardItem(tr("Birth year")));
	model->setHorizontalHeaderItem(3, new QStandardItem(tr("Note")));
	model->setHorizontalHeaderItem(4, new QStandardItem(tr("-")));
	
	view->setColumnWidth(0,20);
	view->setColumnWidth(1,90);
	view->setColumnWidth(2,57);
	view->setColumnWidth(3,40);
	view->setColumnWidth(4,30);
	
	label = new QLabel("Member list");
	topLeftLayout->addWidget(label);
	int rowCurrent = 0;

	MYSQL_RES *res = database::classMember_searchClassId(conn,classId);
	while(MYSQL_ROW classMemberRow = mysql_fetch_row(res))
	{
		QString memberId   = classMemberRow[1];
		MYSQL_ROW memberRow = database::member_searchMemberId(conn,memberId);
		
		model->setItem(rowCurrent, 0, new QStandardItem(memberRow[0]));
		model->setItem(rowCurrent, 1, new QStandardItem(memberRow[1]));
		model->setItem(rowCurrent, 2, new QStandardItem(memberRow[2]));
		model->setItem(rowCurrent, 3, new QStandardItem(memberRow[3]));

		QPushButton *button = new QPushButton("");
		QPixmap pixmap("Resources/Delete_icon.png");
		QIcon buttonIcon(pixmap);
		button->setIcon(buttonIcon);
		QSignalMapper *signalMapper = new QSignalMapper(this);
		signalMapper->setMapping(button,memberId);
		QObject::connect(button,SIGNAL(clicked()),signalMapper,SLOT(map()));
		QObject::connect(signalMapper,SIGNAL(mapped(QString)),this,SLOT(deleteMemberAction(QString)));
		view->setIndexWidget(model->index(rowCurrent,4),button);

		rowCurrent++;
	}
	numOldMemberInDialog = rowCurrent;
	topLeftLayout->addWidget(view);

	QHBoxLayout *horizontalLayout = new QHBoxLayout();
	QPushButton *saveButton = new QPushButton("Save");
	QPixmap pixmap1("Resources/save_icon.png");
	QIcon ButtonIcon1(pixmap1);
	saveButton->setIcon(ButtonIcon1);
	QSignalMapper *saveMapper = new QSignalMapper(this);
	saveMapper->setMapping(saveButton,classId);
	QObject::connect(saveButton,SIGNAL(clicked()),saveMapper,SLOT(map()));
	QObject::connect(saveMapper,SIGNAL(mapped(QString)),this,SLOT(saveListAction(QString)));
	
	horizontalLayout->addWidget(saveButton);
	
	QPushButton *addMemberButton = new QPushButton("Add Member");
	QPixmap pixmap("Resources/add-icon.png");
	QIcon ButtonIcon(pixmap);
	addMemberButton->setIcon(ButtonIcon);
	QObject::connect(addMemberButton,SIGNAL(clicked()),this,SLOT(addMemberAction()));
	horizontalLayout->addWidget(addMemberButton);

	setLayout(topLeftLayout);
	topLeftLayout->addLayout(horizontalLayout);
	setWindowTitle(tr("Member list"));
	setFixedHeight(sizeHint().height());
	
}