Pastie now auto-senses if line-wrap is a bad or good idea. Feedback?
## mark a section (Learn more)
This paste will be private.
package jd.gui.skins.qt; import com.trolltech.qt.gui.*; public class TextAreaDialogImpl extends QDialog { private String text = null; private QPlainTextEdit textedit; TextAreaDialog ui = new TextAreaDialog(); public static String showDialog( String title, String question, String def) { TextAreaDialogImpl tda = new TextAreaDialogImpl(title, question, def); return tda.getText(); } public TextAreaDialogImpl(String title, String question, String def) { TextAreaDialogImpl TextAreaDialogImpl = new TextAreaDialogImpl(); textedit = new QPlainTextEdit(this); TextAreaDialogImpl.ui.verticalLayout.insertWidget(1, textedit); TextAreaDialogImpl.setWindowTitle(title); TextAreaDialogImpl.ui.label.setText(question); textedit.document().setPlainText(def); TextAreaDialogImpl.ui.buttonBox.accepted.connect(this, "buttonClicked()"); TextAreaDialogImpl.show(); // return "abc"; } public void buttonClicked() { //if text=textedit.document().toPlainText(); System.out.println(text); } public String getText() { return text; } public TextAreaDialogImpl() { ui.setupUi(this); } public TextAreaDialogImpl(QWidget parent) { super(parent); ui.setupUi(this); } }
From the Design Piracy series on my blog: