QT学习之路————常用控件、常用操作(持续更新中。。。)

TextEdit控件:

获取控件中的行数(PS:其实是读取控件中有多少个换行符)
int textline=ui->textEdit->document()->lineCount();
读取首行内容:
textEdit->textCursor();
txtcur.setPosition(0);
txtcur.movePosition(QTextCursor::EndOfLine,QTextCursor::KeepAnchor);
QString qstr= txtcur.selectedText();
删除首行内容:
txtcur.movePosition(QTextCursor::Down,QTextCursor::KeepAnchor);
txtcur.movePosition(QTextCursor::StartOfLine,QTextCursor::KeepAnchor);
txtcur.removeSelectedText();
光标移到尾行:
ui->timeInput->moveCursor(QTextCursor::End);

QT中关于字符转换问题

int 转 QString:
int num=100;
QString::number(num,10);   //十进制型转换
QString 转 char *
QString atcmd1="AT+CMGS=\""+ui->number->text()+"\"\r";
char *ph=new char[atcmd1.length()+1];
strcpy(ph,atcmd1.toAscii().constData());

TableWidget控件

QHeaderView *header = ui->tableWidget->verticalHeader();
header->setHidden(true);// 隐藏行号



你可能感兴趣的:(QT学习之路————常用控件、常用操作(持续更新中。。。))