Example #1
1
  private void changeIcon() {
    QIcon icon = new QIcon();

    for (int row = 0; row < imagesTable.rowCount(); ++row) {
      QTableWidgetItem item0 = imagesTable.item(row, 0);
      QTableWidgetItem item1 = imagesTable.item(row, 1);
      QTableWidgetItem item2 = imagesTable.item(row, 2);

      if (item0.checkState() == Qt.CheckState.Checked) {
        QIcon.Mode mode;
        if (item1.text().equals(tr("Normal"))) {
          mode = QIcon.Mode.Normal;
        } else if (item1.text().equals(tr("Active"))) {
          mode = QIcon.Mode.Active;
        } else if (item1.text().equals(tr("Disabled"))) {
          mode = QIcon.Mode.Disabled;
        } else {
          mode = QIcon.Mode.Selected;
        }

        QIcon.State state;
        if (item2.text().equals(tr("On"))) {
          state = QIcon.State.On;
        } else {
          state = QIcon.State.Off;
        }

        String fileName = (String) item0.data(Qt.ItemDataRole.UserRole);
        QImage image = new QImage(fileName);
        if (!image.isNull()) icon.addPixmap(QPixmap.fromImage(image), mode, state);
      }
    }

    previewArea.setIcon(icon);
  }
Example #2
0
    private void updatePixmapLabels() {
      for (int i = 0; i < NumModes; ++i) {
        QIcon.Mode mode;
        if (i == 0) {
          mode = QIcon.Mode.Normal;
        } else if (i == 1) {
          mode = QIcon.Mode.Active;
        } else if (i == 2) {
          mode = QIcon.Mode.Disabled;
        } else {
          mode = QIcon.Mode.Selected;
        }

        for (int j = 0; j < NumStates; ++j) {
          QIcon.State state = (j == 0) ? QIcon.State.Off : QIcon.State.On;
          QPixmap pixmap = icon.pixmap(size, mode, state);
          pixmapLabels[i][j].setPixmap(pixmap);
          pixmapLabels[i][j].setEnabled(!pixmap.isNull());
        }
      }
    }
Example #3
0
  public static void main(String args[]) {
    QApplication.initialize(args);

    QApplication.setWindowIcon(new QIcon(QPixmap.fromImage(qoffeyLogo(64))));

    // QPixmap pm = QPixmap.fromImage(qoffeyLogo(400));

    Image im = new Image();
    im.show();

    QApplication.execStatic();
    QApplication.shutdown();
  }