Results 1 to 2 of 2

Thread: Qt qtoolbutton checkable/checked problem

  1. #1
    Join Date
    Apr 2012
    Posts
    7
    Qt products
    Qt/Embedded
    Platforms
    MacOS X Unix/X11

    Default Qt qtoolbutton checkable/checked problem

    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:n_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:n_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");


    }


    }

  2. #2
    Join Date
    Apr 2012
    Posts
    7
    Qt products
    Qt/Embedded
    Platforms
    MacOS X Unix/X11

    Default Re: Qt qtoolbutton checkable/checked problem

    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?

Similar Threads

  1. QToolButton + style sheet problem
    By John82 in forum Qt Programming
    Replies: 6
    Last Post: 22nd August 2015, 19:37
  2. Replies: 3
    Last Post: 9th June 2011, 12:33
  3. Problem with QToolButton + stylesheet
    By Bagration in forum Qt Programming
    Replies: 0
    Last Post: 14th December 2010, 04:32
  4. QToolbutton:checked -> QIcon:selected not working
    By tomf in forum Qt Programming
    Replies: 4
    Last Post: 21st March 2010, 21:17
  5. Problem with qtoolbutton
    By moowy in forum Qt Programming
    Replies: 1
    Last Post: 22nd September 2006, 13:30

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.