当前位置:   article > 正文

基于IMX6ULL的智能车载终端项目(代码开源)_imx6ull 开源 linux 项目 车载终端(1)_imx6ul项目

imx6ul项目
durationSlider->setObjectName("durationSlider");

/* 音乐列表 */
listWidget = new QListWidget();
listWidget->setObjectName("listWidget");
listWidget->resize(310, 265);
listWidget->setVerticalScrollBarPolicy(
            Qt::ScrollBarAlwaysOff);
listWidget->setHorizontalScrollBarPolicy(
            Qt::ScrollBarAlwaysOff);

/* 列表遮罩 */
listMask = new QWidget(listWidget);
listMask->setMinimumSize(310, 50);
listMask->setMinimumHeight(50);
listMask->setObjectName("listMask");
listMask->setGeometry(0,
                      listWidget->height() - 50,
                      310,
                      50);


/* 设置对象名称 */
pushButton[0]->setObjectName("btn_previous");
pushButton[1]->setObjectName("btn_play");
pushButton[2]->setObjectName("btn_next");
pushButton[3]->setObjectName("btn_favorite");
pushButton[4]->setObjectName("btn_mode");
pushButton[5]->setObjectName("btn_menu");
pushButton[6]->setObjectName("btn_volume");

/* 设置按钮属性 */
pushButton[1]->setCheckable(true);
pushButton[3]->setCheckable(true);

/* H0布局 */
vWidget[0]->setMinimumSize(310, 480);
vWidget[0]->setMaximumWidth(310);
vWidget[1]->setMinimumSize(320, 480);
QSpacerItem *hSpacer0 = new
        QSpacerItem(70, 480,
                    QSizePolicy::Minimum,
                    QSizePolicy::Maximum);

QSpacerItem *hSpacer1 = new
        QSpacerItem(65, 480,
                    QSizePolicy::Minimum,
                    QSizePolicy::Maximum);

QSpacerItem *hSpacer2 = new
        QSpacerItem(60, 480,
                    QSizePolicy::Minimum,
                    QSizePolicy::Maximum);

hBoxLayout[0]->addSpacerItem(hSpacer0);
hBoxLayout[0]->addWidget(vWidget[0]);
hBoxLayout[0]->addSpacerItem(hSpacer1);
hBoxLayout[0]->addWidget(vWidget[1]);
hBoxLayout[0]->addSpacerItem(hSpacer2);
hBoxLayout[0]->setContentsMargins(0, 0, 0, 0);

hWidget[0]->setLayout(hBoxLayout[0]);
setCentralWidget(hWidget[0]);

/* V0布局 */
listWidget->setMinimumSize(310, 265);
hWidget[1]->setMinimumSize(310, 80);
hWidget[1]->setMaximumHeight(80);
label[0]->setMinimumSize(310, 95);
label[0]->setMaximumHeight(95);
QSpacerItem *vSpacer0 = new
        QSpacerItem(310, 10,
                    QSizePolicy::Minimum,
                    QSizePolicy::Maximum);
QSpacerItem *vSpacer1 = new
        QSpacerItem(310, 30,
                    QSizePolicy::Minimum,
                    QSizePolicy::Minimum);
vBoxLayout[0]->addWidget(label[0]);
vBoxLayout[0]->addWidget(listWidget);
vBoxLayout[0]->addSpacerItem(vSpacer0);
vBoxLayout[0]->addWidget(hWidget[1]);
vBoxLayout[0]->addSpacerItem(vSpacer1);
vBoxLayout[0]->setContentsMargins(0, 0, 0, 0);

vWidget[0]->setLayout(vBoxLayout[0]);

/* H1布局 */
for (int i = 0; i < 3; i++) {
    pushButton[i]->setMinimumSize(80, 80);
}
QSpacerItem *hSpacer3 = new
        QSpacerItem(40, 80,
                    QSizePolicy::Expanding,
                    QSizePolicy::Expanding);
QSpacerItem *hSpacer4 = new
        QSpacerItem(40, 80,
                    QSizePolicy::Expanding,
                    QSizePolicy::Expanding);
hBoxLayout[1]->addWidget(pushButton[0]);
hBoxLayout[1]->addSpacerItem(hSpacer3);
hBoxLayout[1]->addWidget(pushButton[1]);
hBoxLayout[1]->addSpacerItem(hSpacer4);
hBoxLayout[1]->addWidget(pushButton[2]);
hBoxLayout[1]->setContentsMargins(0, 0, 0, 0);

hWidget[1]->setLayout(hBoxLayout[1]);

/* V1布局 */
QSpacerItem *vSpacer2 = new
        QSpacerItem(320, 40,
                    QSizePolicy::Minimum,
                    QSizePolicy::Maximum);
QSpacerItem *vSpacer3 = new
        QSpacerItem(320, 20,
                    QSizePolicy::Minimum,
                    QSizePolicy::Maximum);
QSpacerItem *vSpacer4 = new
        QSpacerItem(320, 30,
                    QSizePolicy::Minimum,
                    QSizePolicy::Minimum);
label[1]->setMinimumSize(320, 320);
QImage Image;
Image.load(":/images/cd.png");
QPixmap pixmap = QPixmap::fromImage(Image);
int with = 320;
int height = 320;
QPixmap fitpixmap =
        pixmap.scaled(with, height,
                      Qt::IgnoreAspectRatio,
                      Qt::SmoothTransformation);
label[1]->setPixmap(fitpixmap);
label[1]->setAlignment(Qt::AlignCenter);
vWidget[2]->setMinimumSize(300, 80);
vWidget[2]->setMaximumHeight(80);
vBoxLayout[1]->addSpacerItem(vSpacer2);
vBoxLayout[1]->addWidget(label[1]);
vBoxLayout[1]->addSpacerItem(vSpacer3);
vBoxLayout[1]->addWidget(durationSlider);
vBoxLayout[1]->addWidget(vWidget[2]);
vBoxLayout[1]->addSpacerItem(vSpacer4);
vBoxLayout[1]->setContentsMargins(0, 0, 0, 0);

vWidget[1]->setLayout(vBoxLayout[1]);

/* V2布局 */
QSpacerItem *vSpacer5 = new
        QSpacerItem(300, 10,
                    QSizePolicy::Minimum,
                    QSizePolicy::Maximum);
hWidget[2]->setMinimumSize(320, 20);
hWidget[3]->setMinimumSize(320, 60);
vBoxLayout[2]->addWidget(hWidget[2]);
vBoxLayout[2]->addSpacerItem(vSpacer5);
vBoxLayout[2]->addWidget(hWidget[3]);
vBoxLayout[2]->setContentsMargins(0, 0, 0, 0);

vWidget[2]->setLayout(vBoxLayout[2]);

/* H2布局 */
QFont font;

font.setPixelSize(10);

/* 设置标签文本 */
label[0]->setText("Q Music,Enjoy it!");
label[2]->setText("00:00");
label[3]->setText("00:00");
label[2]->setSizePolicy(QSizePolicy::Expanding,
                        QSizePolicy::Expanding);
label[3]->setSizePolicy(QSizePolicy::Expanding,
                        QSizePolicy::Expanding);
label[3]->setAlignment(Qt::AlignRight);
label[2]->setAlignment(Qt::AlignLeft);
label[2]->setFont(font);
label[3]->setFont(font);

pal.setColor(QPalette::WindowText, Qt::white);
label[0]->setPalette(pal);
label[2]->setPalette(pal);
label[3]->setPalette(pal);

hBoxLayout[2]->addWidget(label[2]);
hBoxLayout[2]->addWidget(label[3]);

hBoxLayout[2]->setContentsMargins(0, 0, 0, 0);
hWidget[2]->setLayout(hBoxLayout[2]);

/* H3布局 */
QSpacerItem *hSpacer5 = new
        QSpacerItem(0, 60,
                    QSizePolicy::Minimum,
                    QSizePolicy::Maximum);
QSpacerItem *hSpacer6 = new
        QSpacerItem(80, 60,
                    QSizePolicy::Maximum,
                    QSizePolicy::Maximum);
QSpacerItem *hSpacer7 = new
        QSpacerItem(80, 60,
                    QSizePolicy::Maximum,
                    QSizePolicy::Maximum);
QSpacerItem *hSpacer8 = new
        QSpacerItem(80, 60,
                    QSizePolicy::Maximum,
                    QSizePolicy::Maximum);
QSpacerItem *hSpacer9 = new
        QSpacerItem(0, 60,
                    QSizePolicy::Minimum,
                    QSizePolicy::Maximum);

for (int i = 3; i < 7; i++) {
    pushButton[i]->setMinimumSize(25, 25);
    pushButton[i]->setMaximumSize(25, 25);
}

hBoxLayout[3]->addSpacerItem(hSpacer5);
hBoxLayout[3]->addWidget(pushButton[3]);
hBoxLayout[3]->addSpacerItem(hSpacer6);
hBoxLayout[3]->addWidget(pushButton[4]);
hBoxLayout[3]->addSpacerItem(hSpacer7);
hBoxLayout[3]->addWidget(pushButton[5]);
hBoxLayout[3]->addSpacerItem(hSpacer8);
hBoxLayout[3]->addWidget(pushButton[6]);
hBoxLayout[3]->addSpacerItem(hSpacer9);
hBoxLayout[3]->setContentsMargins(0, 0, 0, 0);
hBoxLayout[3]->setAlignment(Qt::AlignHCenter);

hWidget[3]->setLayout(hBoxLayout[3]);

//hWidget[0]->setStyleSheet("background-color:red");
//hWidget[1]->setStyleSheet("background-color:#ff5599");
//hWidget[2]->setStyleSheet("background-color:#ff55ff");
//hWidget[3]->setStyleSheet("background-color:black");
//vWidget[0]->setStyleSheet("background-color:#555555");
//vWidget[1]->setStyleSheet("background-color:green");
//vWidget[2]->setStyleSheet("background-color:gray");
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49
  • 50
  • 51
  • 52
  • 53
  • 54
  • 55
  • 56
  • 57
  • 58
  • 59
  • 60
  • 61
  • 62
  • 63
  • 64
  • 65
  • 66
  • 67
  • 68
  • 69
  • 70
  • 71
  • 72
  • 73
  • 74
  • 75
  • 76
  • 77
  • 78
  • 79
  • 80
  • 81
  • 82
  • 83
  • 84
  • 85
  • 86
  • 87
  • 88
  • 89
  • 90
  • 91
  • 92
  • 93
  • 94
  • 95
  • 96
  • 97
  • 98
  • 99
  • 100
  • 101
  • 102
  • 103
  • 104
  • 105
  • 106
  • 107
  • 108
  • 109
  • 110
  • 111
  • 112
  • 113
  • 114
  • 115
  • 116
  • 117
  • 118
  • 119
  • 120
  • 121
  • 122
  • 123
  • 124
  • 125
  • 126
  • 127
  • 128
  • 129
  • 130
  • 131
  • 132
  • 133
  • 134
  • 135
  • 136
  • 137
  • 138
  • 139
  • 140
  • 141
  • 142
  • 143
  • 144
  • 145
  • 146
  • 147
  • 148
  • 149
  • 150
  • 151
  • 152
  • 153
  • 154
  • 155
  • 156
  • 157
  • 158
  • 159
  • 160
  • 161
  • 162
  • 163
  • 164
  • 165
  • 166
  • 167
  • 168
  • 169
  • 170
  • 171
  • 172
  • 173
  • 174
  • 175
  • 176
  • 177
  • 178
  • 179
  • 180
  • 181
  • 182
  • 183
  • 184
  • 185
  • 186
  • 187
  • 188
  • 189
  • 190
  • 191
  • 192
  • 193
  • 194
  • 195
  • 196
  • 197
  • 198
  • 199
  • 200
  • 201
  • 202
  • 203
  • 204
  • 205
  • 206
  • 207
  • 208
  • 209
  • 210
  • 211
  • 212
  • 213
  • 214
  • 215
  • 216
  • 217
  • 218
  • 219
  • 220
  • 221
  • 222
  • 223
  • 224
  • 225
  • 226
  • 227
  • 228
  • 229
  • 230
  • 231
  • 232
  • 233
  • 234
  • 235
  • 236

}

MainWindow::~MainWindow()
{
}

void MainWindow::btn_play_clicked()
{
int state = musicPlayer->state();

switch (state) {
case QMediaPlayer::StoppedState:
    /* 媒体播放 */
    musicPlayer->play();
    break;

case QMediaPlayer::PlayingState:
    /* 媒体暂停 */
    musicPlayer->pause();
    break;

case QMediaPlayer::PausedState:
    musicPlayer->play();
    break;
}
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15

}

void MainWindow::btn_next_clicked()
{
musicPlayer->stop();
int count = mediaPlaylist->mediaCount();
if (0 == count)
ret

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/我家小花儿/article/detail/639162
推荐阅读
相关标签
  

闽ICP备14008679号