Perl Nopaste Service

Download: Here New: Here

Nopaste from: Fri Oct 30 15:12:48 2015

Expires on: never

From: ciclonite (79.41.17.236)

Code language: C++

Description: Qt Pixmap problem

Code:

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:
#include "mainwindow.h"
#include "ui_mainwindow.h"
#include <pigpio.h>
#include <QtGui>
#include <QSize>
#include <QDebug>

#define MIN_TEMP 60
#define MAX_TEMP 249
#define OUT_RES 21
#define OUT_LIGHT 22
#define IN_TMP 23



MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
    ui->setupUi(this);
    QPixmap fire(":/images/Fire.png");
    QPixmap fireScaled = fire.scaled(QSize(131,121),Qt::KeepAspectRatio);
    QPixmap cold(":/images/cold.png");
    QPixmap coldScaled = cold.scaled(QSize(131,121),Qt::KeepAspectRatio);




    if(gpioInitialise()>=0) {

        ui->labelDbg->setText("Inizialization Successfully");
        ui->lcdTempSet->display(150);
        gpioSetMode(21, PI_OUTPUT);
        gpioSetMode(22, PI_OUTPUT);
        gpioSetMode(23, PI_INPUT);
        qDebug() << gpioRead(21);
        if(gpioRead(OUT_RES))
            // Here set the pixmap without problem
            ui->labelResistence->setPixmap(fireScaled);
        else
            ui->labelResistence->setPixmap(coldScaled);

    }



}

void MainWindow::setImage(QPixmap img) {

    ui->labelResistence->setPixmap(img);

}


MainWindow::~MainWindow()
{
    delete ui;
}


void MainWindow::on_ResistenzeOn_clicked()
{

    gpioWrite(21, 1);
    
    // Here there is a problem.. when i call the function the image disappear
    ui->labelResistence->setPixmap(fireScaled);
}

void MainWindow::on_ResistenzeOFF_clicked()
{

    gpioWrite(21, 0);
    
    // Here there is a problem.. when i call the function the image disappear
    ui->labelResistence->setPixmap(coldScaled);
}

void MainWindow::on_temperaturaPiu_clicked()
{

    double val = ui->lcdTempSet->value();
    if(val <= MAX_TEMP)
        ui->lcdTempSet->display(val+1);
}

void MainWindow::on_temperaturaMeno_clicked()
{
    double val = ui->lcdTempSet->value();
    if(val >= MIN_TEMP)
        ui->lcdTempSet->display(val-1);
}