[SOLVED]QFile and QTextStream Question
-
Hii.
void QAbstractSlider::valueChanged ( int value ) [signal]
This signal is emitted when the slider value has changed, with the new slider value as argument.
http://qt-project.org/doc/qt-4.8/qabstractslider.html#valueChanged
This is the signal you need to connect with your slot .just like when you connect your QPushButton's clicked signal to it's Slot_clicked();
hope you know signal and slot
. -
I try it now,
Feel like, i am going to fail my school Final Year Project ... -
So, i need to create another .cpp and .h file for this?
-
because i am now writing this in a function
:
@void Dialog::getValue()
{
int h_slide1 = ui->hueSlide1->value();
QFile valueHSV("/home/pi/valueHSV/hsv.txt");
if(!valueHSV.open(QIODevice::WriteOnly| QIODevice::Text)){
qDebug() << "File not able to open" << endl;
return;
}
QTextStream hsv(&valueHSV);
hsv << h_slide1;
qDebug() << "Value ="<<h_slide1
valueHSV.close();
}@ -
yes you can add another .h and .cpp file .inheriting QWidget class.
-
i need to use MainWindow or Dialog?
-
the function in .h file should be under signals?
-
hi
you can take a reference from the following link
http://www.codeprogress.com/cpp/libraries/qt/qProgressbarSetValueExample.php#.U7J--ZSSwb8[Edited: Remember it is an old example using 4.7]
-
ermm.. this link not working..
-
The example i can understand, but whn the slider move, can i save the current value to a txt file?
-
Hi Lam,
I dont think your suggestion could work, i could not call ui into the function.
-
[quote author="YDYD" date="1404207347"]ermm.. this link not working..[/quote]
link is perfectly working.[quote author="YDYD" date="1404207723"]The example i can understand, but whn the slider move, can i save the current value to a txt file?[/quote]
yes that is why this signal is given.
[quote author="YDYD" date="1404207829"]Hi Lam,
I dont think your suggestion could work, i could not call ui into the function.[/quote]
the example does not use Qt designer Widget it is taking on run time.
I think the problem is you have to understand the basics first like
@
creating .h and .cpp file inheriting QWidget/QMainWindow or Qdialog.
SIGNAL and SLOT
and many more thing.
@ -
ok =)
Thank you.
I am very rush because i was only given 2weeks time to port a project coding into Qt ...Sorry for troubling u all
and Thanks a lot