qt开发的嵌入式界面,按向下按钮不向下移动,向右移动
按向下键后
下面是用到的排列按钮的源程序
QPushButton *btn1 = new QPushButton("ADC",this);
QPushButton *btn2 = new QPushButton("RTC",this);
QPushButton *btn3 = new QPushButton("FRAM",this);
QPushButton *btn4 = new QPushButton("USB",this);
QPushButton *btn5 = new QPushButton("串口",this);
QPushButton *btn6 = new QPushButton("LED",this);
QPushButton *btn7 = new QPushButton("遥信",this);
QPushButton *btn8 = new QPushButton("SPI",this);
QPushButton *btn9 = new QPushButton("Ethernet",this);
QGridLayout *grid = new QGridLayout;
grid->addWidget(btn1,0,0);
grid->addWidget(btn2,0,1);
grid->addWidget(btn3,1,0);
grid->addWidget(btn4,1,1);
grid->addWidget(btn5,2,0);
grid->addWidget(btn6,2,1);
grid->addWidget(btn7,3,0);
grid->addWidget(btn8,3,1);
grid->addWidget(btn9,4,0);
QVBoxLayout *mainLayout = new QVBoxLayout;
mainLayout->setMargin(10);
mainLayout->setSpacing(10);
mainLayout->addLayout(grid);
setLayout(mainLayout);
connect(btn1,SIGNAL(clicked()),this,SLOT(slotADC()));
connect(btn2,SIGNAL(clicked()),this,SLOT(slotRTC()));
connect(btn3,SIGNAL(clicked()),this,SLOT(slotFRAM()));
connect(btn4,SIGNAL(clicked()),this,SLOT(slotUSB()));
connect(btn5,SIGNAL(clicked()),this,SLOT(slotSERIAL()));
connect(btn6,SIGNAL(clicked()),this,SLOT(slotLED()));
connect(btn7,SIGNAL(clicked()),this,SLOT(slotYX()));
connect(btn8,SIGNAL(clicked()),this,SLOT(slotSPI()));
connect(btn9,SIGNAL(clicked()),this,SLOT(slotEthernet()));
大家帮忙看看应该怎么改,才能实现按向下按钮会向下移动而不是向右移动
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
QKeyEvent *e;
我添加了
QWidget::setTabOrder(btn2,btn4);
QWidget::setTabOrder(btn4,btn6);
QWidget::setTabOrder(btn6,btn8);
QWidget::setTabOrder(btn1,btn3);
QWidget::setTabOrder(btn3,btn5);
QWidget::setTabOrder(btn5,btn7);
QWidget::setTabOrder(btn7,btn9);
QWidget::setTabOrder(btn8,btn9);
QWidget::setTabOrder(btn9,btn1);
能实现上下,不能实现左右,后来又仔细想了一下,如果想实现像手机上的上下左右按钮功能,必须每个按钮的四个方向都要考虑。
谢谢,我改一下试试
我的意思是按向下键,应该从ADC移到FRAM,但是却跑到RTC上,这个应该怎么改
没明白你的意思。界面都是直接用QtCreator拖的,很久木有自己写layout的代码了。