public static void main(String args[]) { QApplication.initialize(args); new Icons().show(); QApplication.exec(); }
public static void main(String args[]) { QApplication.initialize(args); new Scribble().show(); QApplication.execStatic(); QApplication.shutdown(); }
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(); }
private void changeStyle(boolean checked) { if (!checked) return; QAction action = (QAction) QSignalEmitter.signalSender(); QStyle style = QStyleFactory.create((String) action.data()); if (style != null) { QApplication.setStyle(style); QApplication.setPalette(style.standardPalette()); } setTextOnRadioButtons(); changeSize(true); }
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] }
// ! [7] protected void mouseMoveEvent(QMouseEvent event) { if (!(event.buttons().isSet(Qt.MouseButton.LeftButton))) return; if ((event.pos().subtract(dragStartPosition)).manhattanLength() < QApplication.startDragDistance()) return; QDrag drag = new QDrag(this); QMimeData mimeData = new QMimeData(); mimeData.setData(mimeType, data); drag.setMimeData(mimeData); Qt.DropAction dropAction = drag.exec(Qt.DropAction.CopyAction, Qt.DropAction.MoveAction); // ! [7] switch (dropAction) { case CopyAction: dragResult.emit(tr("The text was copied.")); break; case MoveAction: dragResult.emit(tr("The text was moved.")); break; default: dragResult.emit(tr("Unknown action.")); break; } // ! [8] }
private void createActions() { addImagesAct = new QAction(tr("&Add Images..."), this); addImagesAct.setShortcut(tr("Ctrl+A")); addImagesAct.triggered.connect(this, "addImages()"); removeAllImagesAct = new QAction(tr("&Remove All Images"), this); removeAllImagesAct.setShortcut(tr("Ctrl+R")); removeAllImagesAct.triggered.connect(this, "removeAllImages()"); exitAct = new QAction(tr("&Quit"), this); exitAct.setShortcut(tr("Ctrl+Q")); exitAct.triggered.connect(this, "close()"); styleActionGroup = new QActionGroup(this); for (String styleName : QStyleFactory.keys()) { QAction action = new QAction(styleActionGroup); action.setText(styleName + " Style"); action.setData(styleName); action.setCheckable(true); action.triggered.connect(this, "changeStyle(boolean)"); } guessModeStateAct = new QAction(tr("&Guess Image Mode/State"), this); guessModeStateAct.setCheckable(true); guessModeStateAct.setChecked(true); aboutAct = new QAction(tr("&About"), this); aboutAct.triggered.connect(this, "about()"); aboutQtAct = new QAction(tr("About &Qt"), this); aboutQtAct.triggered.connect(QApplication.instance(), "aboutQt()"); }
private void changeSize(boolean checked) { if (!checked) return; int extent; if (otherRadioButton.isChecked()) { extent = otherSpinBox.value(); } else { QStyle.PixelMetric metric; if (smallRadioButton.isChecked()) { metric = QStyle.PixelMetric.PM_SmallIconSize; } else if (largeRadioButton.isChecked()) { metric = QStyle.PixelMetric.PM_LargeIconSize; } else if (toolBarRadioButton.isChecked()) { metric = QStyle.PixelMetric.PM_ToolBarIconSize; } else if (listViewRadioButton.isChecked()) { metric = QStyle.PixelMetric.PM_ListViewIconSize; } else if (iconViewRadioButton.isChecked()) { metric = QStyle.PixelMetric.PM_IconViewIconSize; } else { metric = QStyle.PixelMetric.PM_TabBarIconSize; } extent = QApplication.style().pixelMetric(metric); } previewArea.setSize(new QSize(extent, extent)); otherSpinBox.setEnabled(otherRadioButton.isChecked()); }
private void checkCurrentStyle() { for (QAction action : styleActionGroup.actions()) { String styleName = action.data().toString(); QStyle candidate = QStyleFactory.create(styleName); if (candidate.objectName().equals(QApplication.style().objectName())) { action.trigger(); return; } } }
private void setTextOnRadioButtons() { QStyle style = QApplication.style(); int smallIconSize = style.pixelMetric(QStyle.PixelMetric.PM_SmallIconSize); smallRadioButton.setText("Small (" + smallIconSize + " x " + smallIconSize + ")"); int largeIconSize = style.pixelMetric(QStyle.PixelMetric.PM_LargeIconSize); largeRadioButton.setText("Large (" + largeIconSize + " x " + largeIconSize + ")"); int toolBarIconSize = style.pixelMetric(QStyle.PixelMetric.PM_ToolBarIconSize); toolBarRadioButton.setText("Toolbars (" + toolBarIconSize + " x " + toolBarIconSize + ")"); int listViewIconSize = style.pixelMetric(QStyle.PixelMetric.PM_ListViewIconSize); listViewRadioButton.setText("List views (" + listViewIconSize + " x " + listViewIconSize + ")"); int iconViewIconSize = style.pixelMetric(QStyle.PixelMetric.PM_IconViewIconSize); iconViewRadioButton.setText("Icon views (" + iconViewIconSize + " x " + iconViewIconSize + ")"); int tabBarIconSize = style.pixelMetric(QStyle.PixelMetric.PM_TabBarIconSize); tabBarRadioButton.setText("Tab bars (" + tabBarIconSize + " x " + tabBarIconSize + ")"); }
private void createActions() { openAct = new QAction(tr("&Open..."), this); openAct.setShortcut(tr("Ctrl+O")); openAct.triggered.connect(this, "open()"); saveAsActs = new LinkedList<QAction>(); for (QByteArray format : QImageWriter.supportedImageFormats()) { String text = new String(format.toByteArray()).toUpperCase() + "..."; QAction action = new QAction(text, this); action.setData(format); action.triggered.connect(this, "save()"); saveAsActs.add(action); } printAct = new QAction(tr("&Print..."), this); printAct.triggered.connect(scribbleArea, "print()"); exitAct = new QAction(tr("E&xit"), this); exitAct.setShortcut(tr("Ctrl+Q")); exitAct.triggered.connect(this, "close()"); penColorAct = new QAction(tr("&Pen Color..."), this); penColorAct.triggered.connect(this, "penColor()"); penWidthAct = new QAction(tr("Pen &Width..."), this); penWidthAct.triggered.connect(this, "penWidth()"); clearScreenAct = new QAction(tr("&Clear Screen"), this); clearScreenAct.setShortcut(tr("Ctrl+L")); clearScreenAct.triggered.connect(scribbleArea, "clearImage()"); aboutAct = new QAction(tr("&About"), this); aboutAct.triggered.connect(this, "about()"); aboutQtAct = new QAction(tr("About &Qt"), this); aboutQtAct.triggered.connect(QApplication.instance(), "aboutQt()"); }