• 4297阅读
  • 3回复

[提问]Qt中是否有多重Map/哈希 [复制链接]

上一主题 下一主题
离线weichanghe
 

只看楼主 正序阅读 楼主  发表于: 2016-01-24
大家好,有下面的一个文本文件,想用Qt处理得到下面的效果:

mapNumLetter[题号][QUES]     = 题目,
mapNumLetter[题号][STAND]   = 标准答案,
mapNumLetter[题号][选项序号] = 选项值,
例如:

mapNumLetter['3.']['QUES']    = 'It is better to add a semicolon at the end of line in block in order to build a good program style.'
mapNumLetter['3.']['STAND']  = 'A'
mapNumLetter['3.']['A.']         = 'True'
...............

mapNumLetter['10.']['QUES']   = 'The ____ function removes the given key (and its corresponding value) from the hash.'
mapNumLetter['10.']['STAND'] = 'D'
mapNumLetter['10.']['A.']        = 'del'
...............

mapNumLetter['34.']['QUES']   = '"1 $1" is generated by ____  while my $price=1;'
mapNumLetter['34.']['STAND'] = 'A'
mapNumLetter['34.']['A.']        = 'print <<EOF;        \
                                                  "$price \$1"     \
                                                   EOF'

mapNumLetter['34.']['B.']       = 'print <<'EOF';    \
                                                 "$price \$1"       \
                                                  EOF'
.....................

但不知道Qt 中是否支持多重哈希Key,如何赋值,大神们能够指导下小白吗?


例如perl中多重哈希Key可以记作:
$hExam{'3.'}{'QUES'}  = 'It is better to add a semicolon at the end of line in block in order to build a good program style.';


输入文件为:
  1. 3. It is better to add a semicolon at the end of line in block        ( A )
  2. in order to build a good program style.                      
  3. A. True            B. Flase
  4. 10.The ____ function removes the given key                            ( D )
  5. (and its corresponding value)
  6. from the hash.            
  7. A. del             B. remove        C. cut             D. delete
  8. 34."1 $1" is generated          
  9. by ____  while my $price=1;     ( A )
  10. A.  print <<EOF;        \
  11.     "$price \$1"     \
  12.     EOF              
  13. B. print <<'EOF';    \
  14.    "$price \$1"       \
  15.    EOF              
  16. C. print <<`EOF`;                   \
  17.    echo "$price \$1" `date +%Y`    \
  18.    EOF





离线sevencat

只看该作者 3楼 发表于: 2016-01-25
你这不叫多重hash,你要的是再定义个结构
class 题号信息
{
string ques;
string stand;
string xdda;
};
战争就是和平,自由就是奴役,愚味就是力量
离线weichanghe

只看该作者 2楼 发表于: 2016-01-24
回 stlcours 的帖子
stlcours:http://doc.qt.io/qt-4.8/qmultihash.html
http://doc.qt.io/qt-4.8/qmultimap.html (2016-01-24 19:38) 

你好,这个Qt自带的Help我已经看过了,但是对于小白用户,看来就跟没看一样。
我还是不知道怎么实现类似下面的效果:
mapNumLetter[题号][QUES]     = 题目,
mapNumLetter[题号][STAND]   = 标准答案,
mapNumLetter[题号][选项序号] = 选项值,
离线stlcours

只看该作者 1楼 发表于: 2016-01-24
快速回复
限100 字节
 
上一个 下一个