zoukankan      html  css  js  c++  java
  • C#+ html 实现类似QQ聊天界面的气泡效果

    1 /**定义两个人的头像*/
    2     Myhead = "<img src=qrc:/chatdemo/Msg/Head.png width='30px'heigth='30px'>";
    3     QString strHead = QString("C:/Users/tax10_000/Desktop/ql_184555_828078.jpg");
    4     otherhead = QString ("<img src=%1 width='30px' heigth='30px'>").arg(strHead);

    加载html文件

     1 void chatdemo::slot_btnpicClicked()
     2 {
     3     QString FilePath = QFileDialog::getOpenFileName();
     4     QFile file( FilePath );
     5     bool ok = file.open( QIODevice::ReadOnly );
     6     if( !ok ) { return; }
     7     QString msg = QString("<img src=%1 />")
     8         .arg( FilePath );
     9     QString MyHead = QString("<img src=%1 width='30px' heigth='30px'/>").arg(FilePath);
    10     QString Msg = QString ("<img src=qrc:/chatdemo/Msg/downloading.jpg/>");
    11     SendMsgShow(msg,MyHead);
    12     RevMsgShow( Msg,otherhead);
    13 
    14 }1
    15 2
    16 3
    17 4
    18 5
    19 6
    20 7
    21 8
    22 9
    23 10
    24 11
    25 12
    26 13
    27 14
    28 
    29 
    30 
    31 下面这个函数的功能是当LineEdit中有内容时,将LineEdit中的内容显示在界面上并清除LineEdit中的内容,如果发送是“你好”或者“时间”时,假设对方会回答你。
    32 
    33 void chatdemo::slot_lineEditReturnpressed()
    34 {
    35     if( m_ui.lineEdit->text() == NULL )
    36     {
    37         QMessageBox::warning( this , "warning","Can't send an empty msg!" );
    38         return;
    39     }
    40     /**自己发送的消息*/
    41     SendMsgShow( m_ui.lineEdit->text() , Myhead );
    42 
    43     if( m_ui.lineEdit->text() == QString::fromLocal8Bit("你好") )
    44     {
    45         RevMsgShow( QString::fromLocal8Bit( "请问有什么可以帮助你吗?" ), otherhead );
    46     }
    47     else if(m_ui.lineEdit->text() == QString::fromLocal8Bit( "时间" ) )
    48     {
    49         RevMsgShow( QString::fromLocal8Bit( "北京时间:%1" )
    50                     .arg( QTime::currentTime().toString( "hh:mm:ss" ) ), otherhead );
    51     }
    52 
    53     m_ui.lineEdit->clear();
    54 }
  • 相关阅读:
    数据库基础+重置root密码
    Bug定级
    测试用例和测试方法
    测试基础
    HDOJ-1010 Tempter of the Bone(dfs)
    POJ
    HDU-2089 不要62 (数位DP)
    Happy!
    LOJ-1422 万圣节服装
    数字三角形(数塔问题)
  • 原文地址:https://www.cnblogs.com/endv/p/6018115.html
Copyright © 2011-2022 走看看