public static void main(String args[]) {
    QApplication.initialize(args);
    // ! [0]
    QLabel label = new QLabel();
    label.setFrameStyle(QFrame.Shadow.Sunken.value() | QFrame.Shape.Panel.value());
    label.setText("first line\nsecond line");
    label.setAlignment(Qt.AlignmentFlag.AlignBottom, Qt.AlignmentFlag.AlignRight);
    // ! [0]

    // ! [1]
    QLineEdit phoneEdit = new QLineEdit();
    QLabel phoneLabel = new QLabel("Phone:");
    phoneLabel.setBuddy(phoneEdit);
    // ! [1]

    // ! [2]
    QLineEdit nameEd = new QLineEdit();
    QLabel nameLb = new QLabel("Name:");
    nameLb.setBuddy(nameEd);
    QLineEdit phoneEd = new QLineEdit();
    QLabel phoneLb = new QLabel("Phone:");
    phoneLb.setBuddy(phoneEd);
    // (layout setup not shown)
    // ! [2]

  }
示例#2
0
  void setData(String mimetype, QByteArray newData) {
    mimeType = mimetype;
    data = new QByteArray(newData);

    dragDropLabel.setText(String.valueOf(data.size()) + " bytes.");

    List<String> formats = new Vector<String>();
    formats.add(mimetype);
    mimeTypes.emit(formats);
  }