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] }
private QLabel createPixmapLabel() { QLabel label = new QLabel(); label.setEnabled(false); label.setAlignment(Qt.AlignmentFlag.AlignCenter); label.setFrameShape(QFrame.Shape.Box); label.setSizePolicy(QSizePolicy.Policy.Expanding, QSizePolicy.Policy.Expanding); label.setBackgroundRole(QPalette.ColorRole.Base); label.setAutoFillBackground(true); label.setMinimumSize(132, 132); return label; }
public dragwidget(QWidget parent) { super(parent); setFrameStyle(QFrame.Shape.StyledPanel.value() | QFrame.Shadow.Sunken.value()); dragDropLabel = new QLabel("", this); dragDropLabel.setAlignment(new Qt.Alignment(Qt.AlignmentFlag.AlignHCenter)); QHBoxLayout layout = new QHBoxLayout(this); layout.addStretch(0); layout.addWidget(dragDropLabel); layout.addStretch(0); setAcceptDrops(true); }
private QLabel createHeaderLabel(String text) { QLabel label = new QLabel(tr("<b>" + text + "</b>")); label.setAlignment(Qt.AlignmentFlag.AlignCenter); return label; }