qt EditLine 读取 显示

qt EditLine 读取 显示,第1张

1connect(&button,SIGNAL(clicked()),this,SLOT(copy())

试试。

2

connect(sender, signal, receiver, slot)

即当sender的signal被触发时,由receiver的slot来响应。

如果你重载了QLineEdit:

class QMyLineEdit : public QLineEdit {

//

}

并重写了copy方法:

void QMyLineEdit::copy()

{

QString str;

str = editline->text();

editline2->setText(str);

QLineEdit::copy();

}

然后:

QMyLineEdit editline2;

那么,你的代码是可行的。

3QLineEdit::copy [slot]的默认行为是把编辑框中的文本传递到剪贴板中的。如果这里的copy只是根据第一个编辑框的内容来设置第二个编辑框的内容,建议换成其它函数名。

也可以用提升类的方法,再重写鼠标点击事件(看懂了的话就不要看下面的废话啦~)

写一个继承自QLineEdit的类

重写其mousePressEvent(QMouseEvent event),函数里写d出对话框的内容

在你含有LineEdit的ui界面里 ,把界面上的QLineEidt右键-提升类,填入你刚刚新建的类

提升完毕运行界面就实现啦~~

我擦, 你这要能写进去才怪呢。

你obtainputname函数里的一个临时变量想要在这个函数外面使用??

// FILE fp;

// string strname;

// fp=fopen("Macrotestini","w+");

connect(lineEdit,SIGNAL(editingFinished()),this,SLOT(obtainputname()));

// const char str1=strnamec_str();

// fprintf(fp, "%s\n", str1);

void obtainputname()

{

QString strname = lineEdit->text();

FILE fp;

fp=fopen("Macrotestini","w+");

fprintf(fp, "%s\n", strnametoLatin1()data());

fclose(fp);

}

QT中提取QTextEdit文本框中的内容,代码如下

int a[100];

QString str = ui->textEdit->toPlainText();

int len = strlength();

for(int i = 0; i < len; ++i)

{

QChar t = strat(i);

a[i] = ttoAscii() - '0';

}

'textEdit的数据合理性以及数组大小自己去设定

以上就是关于qt EditLine 读取 显示全部的内容,包括:qt EditLine 读取 显示、qt 中怎么点击lineedit输入框,d出对话框、QT如何获取文本框中输入的内容等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!

欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/web/9447388.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2023-04-28
下一篇2023-04-28

发表评论

登录后才能评论

评论列表(0条)

    保存