PDA

View Full Version : Qt qtoolbutton checkable/checked problem



wilcd
12th April 2012, 18:25
Hi,i've some code,it works according a configuration stored at a microsd,for my config screen i've made a QT UI FORM with different buttons .. i assigned 1button named LISTICON with 2 different icons,NORMAL OFF & AND NORMAL ON at the qt ui form tool , clicked CHECKABLE,it's possible to check there if it's checked or not ... i made boolean for it .. connected the button to the signal slot something like SENDER--->btListicon ----> Signal (toggled(bool) --->Receiver (btListicon) --> Slot SetCheck(bool)

using the boolean to my specific function works ... it saves the change to the microsd when i click over the button ,, the issue comes now,at the beginning i make a setup of the UI,the QT UI FORM forces the UI
to a checked or unchecked depending the option clicked .. what¡'s the problem ?

i want to set the button using the value at the microsd just at the beginning,overriding the setup value o simply upgrading after the setup is done ,, i read the value at the microsd and then set the boolean but it's setuped by the FORM .h,if i try to override the application suddenly finishes...

BOOLEAN CONNECTED TO THE SIGNAL MADE IN QT FORM UI DESIGNER
void config::on_btListicon_clicked(bool checked)
{
this->activo = checked;
}

NOW I TRY TO OVERRIDE THE VALUE WHICH .H QT FORM MAKES
config::config(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::config)
{
config::miravalores(); /// this function looks for the value stored at the microsd txt file
ui->setupUi(this);

}

here is my function to look for the value inside microsd txt file and trying to override

void config::miravalores()
{

cambio.open(QIODevice::ReadWrite | QIODevice::Text);
cambio.seek(0x00);
cambio.read(valorenconfig,65);
if (valorenconfig[62]==0X79 || valorenconfig[62]==0X59)
{
ui->btListicon->setChecked(true);
}
else
{
ui-btListicon->setChecked(flase);
}

cambio.close();
}

some solution ?? i can confirm that the boolean and the button icon works changing and saving the stored value to a new one after click over it...the icon changes,and the value gets correctly stored,my problem is that when i go out of this QMainWindow and i reenter i always get the setup forced value icon and not the one which i try to read inside the file with "miravalores" function to REFRESH/UPGRADE

FUNCTION WORKING OK


void config::on_btListicon_released()
{

if (activo)
{

QProcess::execute("mount -o remount rw /dos");

cambio.open(QIODevice::ReadWrite | QIODevice::Text);

cambio.seek(62);
cambio.write("N");

cambio.close();
QProcess::execute("mount -o remount -r y -rw /dos");

}
else
{


QProcess::execute("mount -o remount rw /dos");

cambio.open(QIODevice::ReadWrite | QIODevice::Text);

cambio.seek(62);
cambio.write("Y");

cambio.close();
QProcess::execute("mount -o remount -r y -rw /dos");


}


}

wilcd
13th April 2012, 21:04
well,,i've semifixed it making a function which checks the values at the microsd and repainting the Qicon ,, it works ok excepting the first time which i enter at the window,for some reason it sets all the values as off,looks like it doesnt read the values file but it's being reading because the second time at the window the values are there .. any ideas?