zoukankan      html  css  js  c++  java
  • QT要点

    1. QT设计器最终会被解释为ui_**.h。

    2. QString与init之间的转换:

    QString转int:

    bool bIsOk;

    int a = str.toInt( &bIsOk, 10 );

    int转QString

    QString str = QString::number( a, 10 );

    3. QString与char*之间的转换

    const char *p = qstr.toLocal8Bit().data();

    const char *p = qstr.tostdString().data();

     4. 显示对话框

    消息提示 QMessageBox::information( NULL, "Info", "ShowText", QMessageBox::Yes | QMessageBox::No, NULL ); 

    询问 QMessageBox::question( NULL, "Question", "ShowText", QMessageBox::Yes | QMessageBox::No, NULL );

    警告 QMessageBox::warning( NULL, "Warning", "ShowText", QMessageBox::Yes | QMessageBox::No, NULL );

    5. lineEdit

    获取文本内容lineEdit.text();

    设置文本内容lineEdit.setText( QString str );

    6. 创建对话框过程

    (1)创建ui,设计器最好直接带class。

    (2)在设计器中添加form窗体。

    (3)在主文件中包含窗体文件。

    (4)创建窗体类,并实例化,显示即可。

    7. QT中设置对话框居中显示

    #include <QDesktopwidget>

    int positionX = ( QApplication::desktop()->width-dialog->width )/2;

    int positionY = ( QApplication::desktop()->height-dialog->height)/2;

    dialog.move( positionX, positionY );

  • 相关阅读:
    【LeetCode】155. Min Stack 最小栈
    【Java】修改Eclipse默认编码
    负数取模
    【算法第四版笔记】1.1 基础编程模型
    【计算方法】02
    【计算方法】01
    【Java】Java8中List排序
    选择排序算法
    排序算法
    【Java】Eclipse修改JSP文件默认编码
  • 原文地址:https://www.cnblogs.com/MiniHouse/p/3618798.html
Copyright © 2011-2022 走看看