qlineedit

Set QLineEdit focus in Qt

女生的网名这么多〃 提交于 2019-11-27 02:35:32
问题 I am having a qt question. I want the QLineEdit widget to have the focus at application startup. Take the following code for example: #include <QtGui/QApplication> #include <QtGui/QHBoxLayout> #include <QtGui/QPushButton> #include <QtGui/QLineEdit> #include <QtGui/QFont> int main(int argc, char *argv[]) { QApplication app(argc, argv); QWidget *window = new QWidget(); window->setWindowIcon(QIcon("qtest16.ico")); window->setWindowTitle("QtTest"); QHBoxLayout *layout = new QHBoxLayout(window); /

How to get text in QlineEdit when QpushButton is pressed in a string?

孤者浪人 提交于 2019-11-26 11:09:01
问题 I am trying to implement a function. My code is given below. I want to get the text in lineedit with objectname \'host\' in a string say \'shost\' when the user clicks the pushbutton with name \'connect\'. How can I do this? I tried and failed. How do I implement this function? import sys from PyQt4.QtCore import * from PyQt4.QtGui import * class Form(QDialog): def __init__(self, parent=None): super(Form, self).__init__(parent) le = QLineEdit() le.setObjectName(\"host\") le.setText(\"Host\")