Qt--划分画面并能拖拉

一、效果

 

二、创建对象

//
/* 主预览界面部件 */
QWidget *wd_preview;
QWidget *wd_previewDiv;     /* 画面划分 */
QLabel *lb_display;
QLabel *lb_display1;
QLabel *lb_display2;
QLabel *lb_display3;
QLabel *lb_display4;
QLabel *lb_display5;
QLabel *lb_display6;
QLabel *lb_display7;
QString lbStyle = "border: 1px groove gray";   /* label样式表 */
QScrollArea  *sa_div;   /* 画面滑动创建 */
//

 

三、代码

//
/* 获得副主界面的宽和高 */
getWidgetSize();
/* 控制面板widget初始化 */
wd_preview = new QWidget(ui->wd_main);
wd_preview->resize(wdMainWidth, wdMainHeight);
/* 继承wd_preview的子部件初始化 */
/* 画面划分 */
wd_previewDiv = new QWidget(wd_preview);
wd_previewDiv->resize(wdMainWidth * 4/5, wdMainHeight * 2);
wd_previewDiv->setStyleSheet(lbStyle);  /* 样式 */
/* 滑动区域 */
sa_div = new QScrollArea(wd_preview);
sa_div->setWidget(wd_previewDiv);
sa_div->resize(wdMainWidth * 4/5, wdMainHeight);
sa_div->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);   /* 隐藏滑动条 */
sa_div->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
/* 划分8个画面 */
lb_display = new QLabel(wd_previewDiv);
lb_display->resize(wdMainWidth *2/5, wdMainHeight/2);
lb_display1 = new QLabel(wd_previewDiv);
lb_display1->resize(wdMainWidth *2/5, wdMainHeight/2);
lb_display1->move(wdMainWidth *2/5, 0);
lb_display2 = new QLabel(wd_previewDiv);
lb_display2->resize(wdMainWidth *2/5, wdMainHeight/2);
lb_display2->move(0, wdMainHeight/2);
lb_display3 = new QLabel(wd_previewDiv);
lb_display3->resize(wdMainWidth *2/5, wdMainHeight/2);
lb_display3->move(wdMainWidth *2/5, wdMainHeight/2);
lb_display4 = new QLabel(wd_previewDiv);
lb_display4->resize(wdMainWidth *2/5, wdMainHeight/2);
lb_display4->move(0, wdMainHeight);
lb_display5 = new QLabel(wd_previewDiv);
lb_display5->resize(wdMainWidth *2/5, wdMainHeight/2);
lb_display5->move(wdMainWidth *2/5, wdMainHeight);
lb_display6 = new QLabel(wd_previewDiv);
lb_display6->resize(wdMainWidth *2/5, wdMainHeight/2);
lb_display6->move(0, wdMainHeight * 3/2);
lb_display7 = new QLabel(wd_previewDiv);
lb_display7->resize(wdMainWidth *2/5, wdMainHeight/2);
lb_display7->move(wdMainWidth *2/5, wdMainHeight * 3/2);
/* 双击触发,画面放大或回到初始值 */
connect(lb_display, SIGNAL(setQlabel()), this, SLOT(setQalbelSlot()));
videoDis.setResultWidget(listWidget);
//

 

四、双击触发

//
/* 鼠标双击事件 */
void frmMain::mouseDoubleClickEvent(QMouseEvent *e)
{
    emit setQlabel();
    qDebug() << "double clicked!";
}
//

 

 

 

展开阅读全文

没有更多推荐了,返回首页

©️2019 CSDN 皮肤主题: 技术黑板 设计师: CSDN官方博客
应支付0元
点击重新获取
扫码支付

支付成功即可阅读