RecordControlApplication/Menu.cpp
2024-01-17 23:41:43 -08:00

43 lines
1014 B
C++

#include "Menu.h"
#include "ui_Menu.h"
Menu::Menu(QWidget* parent)
: QWidget(parent)
, ui(new Ui::Menu)
{
ui->setupUi(this);
ui->btnChannelA->setChecked(true);
// set window background transparent
// QPalette pal = palette();
// pal.setBrush(QPalette::Base, Qt::transparent);
// setPalette(pal);
// setAttribute(Qt::WA_TranslucentBackground, true);
QPoint globalPos = parent->mapToGlobal(QPoint(0, 0)); //父窗口绝对坐标
int x = globalPos.x() + (parent->width() - this->width()) / 2; //x坐标
int y = globalPos.y() + (parent->height() - this->height()) / 2; //y坐标
this->move(x, y); //窗口移动
}
Menu::~Menu()
{
delete ui;
}
QString Menu::getCurChannel()
{
if (ui->btnChannelA->isChecked())
return "HDMI-A";
else
return "HDMI-B";
}
void Menu::setCurChannel(QString channel)
{
if (channel == "HDMI-A")
ui->btnChannelA->setChecked(true);
else
ui->btnChannelB->setChecked(true);
}