QActionGroup - setExclusive(互斥)
生活随笔
收集整理的這篇文章主要介紹了
QActionGroup - setExclusive(互斥)
小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.
QActionGroup類將actions分組,默認情況下是互斥狀態(tài),在同一時刻所有這些actions只能有一個被激活。
pActionGroup = new QActionGroup(this); pActionGroup ->addAction(leftAlignAct); pActionGroup ->addAction(rightAlignAct); pActionGroup ->addAction(justifyAct); pActionGroup ->addAction(centerAct);當組內(nèi)的某個action被選中的時候,QActionGroup就會發(fā)射triggered()信號。通常情況下,組內(nèi)的每個action發(fā)射自己的triggered()信號。
如果創(chuàng)建一個action group而不想使actions是互斥關(guān)系,那么你可以通過調(diào)用setExclusive(false)來關(guān)閉互斥關(guān)系。
可以通過在group中添加分割線使得各個action分開顯示,可以使用QAction的setSeparator()添加分割線。
one=new QAction("one",this); two=new QAction("two",this); three=new QAction("three",this); one->setCheckable(true);//支持checkable two->setCheckable(true); three->setCheckable(true); QMenu *file=ui->menuBar->addMenu("&File"); group=new QActionGroup(this); file->addAction(group->addAction(one)); file->addAction(group->addAction(two)); file->addAction(group->addAction(three)); group->setExclusive(true);//設(shè)置互斥屬性 one->setChecked(true);//默認選one?
總結(jié)
以上是生活随笔為你收集整理的QActionGroup - setExclusive(互斥)的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 门禁系统服务器在哪,门禁系统知多少?最全
- 下一篇: redis命令之set和zset的操作