QT如何获取用户在QLineEdit的输入

fengye_aitk 2010-03-25 04:37:03
如题。
举个例子:
QLineEdit lineedit = new QLineEdit();
QPushButton button = new QPushButton();
我点击这个Button时我要把用户在lineedit内输入的文本拿到,如何拿?

而且之前lineedit没有setText();
直接用lineedit.text()拿到的是空的。

是不是要在lineedit.text()之前必须要setText()才能拿到?
如果要在这之前set的话,那我如何动态的去获取到用户输入的信息,然后将信息setText()进去呢?

用什么方法动态获取用户输入的信息。在没有setText()之前。

急!!!大家帮帮忙。。
...全文
5567 5 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
knightzhuwei 2010-03-25
  • 打赏
  • 举报
回复
哦 对了 我忘了QT也是有java版的。。我回的是c++。。
fengye_aitk 2010-03-25
  • 打赏
  • 举报
回复
顺便加一个问题:
如何获取一个QGroupBox内选中的单选按钮?
例如:
QRadioButton aRadioButton = new QRadioButton(groupBox);
QRadioButton aRadioButton.setObjectName("T9911RadioButton");
QRadioButton aRadioButton.setGeometry(new QRect(0, 10, 51, 16));

QRadioButton bRadioButton = new QRadioButton(groupBox);
QRadioButton bRadioButton.setObjectName("diguRadioButton");
QRadioButton bRadioButton.setGeometry(new QRect(50, 10, 51, 17));

QRadioButton cRadioButton = new QRadioButton(groupBox);
QRadioButton cRadioButton.setObjectName("sinaRadioButton");
QRadioButton cRadioButton.setGeometry(new QRect(100, 10, 51, 17));

这几个都是在groupBox里的单选按钮。如果我目前是选中aRadioButton的话,我怎么获取得到这个组内
aRadioButton的objectName?

语言是java...
fengye_aitk 2010-03-25
  • 打赏
  • 举报
回复
用的是JAVA,不好意思,我没有说明。
fengye_aitk 2010-03-25
  • 打赏
  • 举报
回复
用的是JAVA,不好意思,我没有说明。
knightzhuwei 2010-03-25
  • 打赏
  • 举报
回复 2
QLineEdit *lineedit = new QLineEdit();
QString s=lineedit->text();

62,634

社区成员

发帖
与我相关
我的任务
社区描述
Java 2 Standard Edition
社区管理员
  • Java SE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧