布局管理器--代码运用 setBuddy

设置三个标签,每个标签对应一个输入框,并且每个标签设置了各自的快捷键。将标签与输入框连接起来。

//设置标签并设置快捷键
QLabel *stringLabel1 = new QLabel("字符串:(&A)");
QLabel *stringLabel2 = new QLabel("字符串:(&B)");
QLabel *stringLabel3 = new QLabel("字符串:(&C)");

QLineEdit *stringLineEdit1 = new QLineEdit;
QLineEdit *stringLineEdit2 = new QLineEdit;
QLineEdit *stringLineEdit3 = new QLineEdit;

//设置伙伴关系
stringLineEdit1->setBuddy(stringLabel1);
stringLineEdit2->setBuddy(stringLabel2);
stringLineEdit3->setBuddy(stringLabel3);

 

相关文章:

  • 2022-12-23
  • 2021-04-12
  • 2021-06-02
  • 2021-07-19
  • 2021-05-27
  • 2021-06-03
  • 2021-07-29
  • 2021-05-28
猜你喜欢
  • 2022-01-04
  • 2021-05-20
  • 2022-12-23
  • 2021-11-29
  • 2021-09-29
  • 2021-10-31
  • 2022-12-23
相关资源
相似解决方案