Trying to populate values on my calendar widget
-
Hello,
I have written a code to write data into a text file and read/load data from the same text file successfully with a click on a button.
Now the requirement is to populate the data in the text file on my widget. Its a calendar widget taken from one of the Qt examples. I looked into something called tablewidget, but I dont think I can apply that concept here since this might not be a table widget. I am deploying my widget on my acer tab.
Can somebody help me with this ? as I am new to coding.
This is how my .cpp file looks . It has two functions one for writing and another for loading data.
generating :
void Window::generatedata (){
// QString var1,var2,var3,var4,var5,var6;
bool x10;
bool y11;
bool z,w;
int year,year1,year2;
int month,month1,month2;
int comb1,comb2,comb3,comb4,comb5;
QString textinput;x10 = gridCheckBox->isChecked(); y11 = navigationCheckBox->isChecked(); z = firstFridayCheckBox->isChecked(); w = mayFirstCheckBox->isChecked(); year = currentDateEdit->date().year(); month = currentDateEdit->date().month(); // QString var1= QString::number(year); // QString var2= QString::number(month); // QDate::toString with format==dd/MM/yyyy year1 = minimumDateEdit->date().year(); month1 = minimumDateEdit->date().month(); // QString var3= QString::number(year1); // QString var4= QString::number(month1); year2 = maximumDateEdit->date().year(); month2 = maximumDateEdit->date().month(); // QString var5= QString::number(year2); //QString var6= QString::number(month2); comb1 = localeCombo->currentIndex(); comb2 = firstDayCombo->currentIndex(); comb3 = selectionModeCombo->currentIndex(); comb4 = firstDayCombo->currentIndex(); comb5 = horizontalHeaderCombo->currentIndex(); textinput = text->text(); button->setText("clicked"); QString outputFilename = "/storage/sdcard0/Download/out.txt"; QFile outputFile(outputFilename); outputFile.open(QIODevice::WriteOnly); QTextStream outStream(&outputFile); if(!outputFile.isOpen()){ // qDebug() << argv[0] << "- Error, unable to open" << outputFilename << "for output"; return ; } outStream << "year="; outStream << year; outStream << "\n"; outStream << "month= "; outStream << month; outStream << "\n"; outStream << "year1= "; outStream << year1; outStream << "\n"; outStream << "month1 = "; outStream << month1; outStream << "\n"; outStream << "year2= "; outStream << year2; outStream << "\n"; outStream << "month2 = "; outStream << month2; outStream << "\n"; outStream << "x10 = "; outStream << x10; outStream << "\n"; outStream << "y11 = "; outStream << y11; outStream <<"\n"; outStream << "z = "; outStream << z; outStream << "\n"; outStream << "w ="; outStream << w; outStream << "\n"; outStream << "comb1 ="; outStream << comb1; outStream << "\n"; outStream << "comb2 ="; outStream << comb2; outStream << "\n"; outStream << "comb3 ="; outStream << comb3; outStream << "\n"; outStream << "comb4 ="; outStream << comb4; outStream << "\n"; outStream << "comb5 ="; outStream << comb5; outStream << "\n"; outStream << "textinput ="; outStream << textinput; outStream << "\n"; outputFile.close();
}
void Window::loaddata ()
{
QString texte; button1->setText("loaded"); zoneTexte.setGeometry(200,200,600,400); zoneTexte.setReadOnly(true);
QFile file("/storage/sdcard0/Download/out.txt");
if(file.open(QIODevice::ReadOnly | QIODevice::Text))
{
texte = file.readAll();
file.close();
}else texte = "cannot open file";
zoneTexte.setText(texte);
zoneTexte.show();
file.close();}
can somebody pls help me out ?
Thanks in advance,
Mansi -
Hi,
Please enclose your code with coding tags (one @ a the beginning and one at the end) otherwise is very difficult to read it
-
Hi,
I solved it by myself :) thanks a lot for your reply :)
Had another issue.
Can gif images work on Qt GUI application ?
I am actually trying to make animated image work but it isn't working, but it works when I use Qt quick application.
Is it even possible to make it work in Qt GUI ??thanks a lot in advance,
Mansi -
Do you mean an animated gif ? IIRC you can use QMovie for that
-
@
#include "guianimation.h"#include <QApplication>
#include <QMovie>
#include <qmovie.h>
#include <QtWidgets>
#include <QLabel>int main(int argc, char *argv[])
{QApplication a(argc, argv);
QLabel *label= new QLabel;
QMovie *movie = new QMovie;movie->setFileName("movie1.gif"); // label->setFixedSize(100,100); label->setMovie(movie); movie->start(); label->show();
guianimation w;
w.show();return a.exec();
}
@ -
Is there any problem with the code ?
-
no problem with the code. It builds fine but when i run it .. animation doesnt work on my tab.
I used this extra line in my main program Q_IMPORT_PLUGIN(qgif)
and some changes in .pro file. This is how my .pro file looks
@#-------------------------------------------------Project created by QtCreator 2013-08-28T16:04:07
#-------------------------------------------------
QT += core gui
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
TARGET = guianimation
TEMPLATE = app
QTPLUGIN += qgifSOURCES += main.cpp
guianimation.cppHEADERS += guianimation.h
FORMS += guianimation.ui
CONFIG += mobility
MOBILITY =
RESOURCES +=
movie2.qrc#CONFIG += static
#QTPLUGIN += qgif
OTHER_FILES +=
android/version.xml
android/res/values-id/strings.xml
android/res/values-nl/strings.xml
android/res/values-ru/strings.xml
android/res/values-zh-rCN/strings.xml
android/res/values-nb/strings.xml
android/res/values-rs/strings.xml
android/res/values-zh-rTW/strings.xml
android/res/values-fa/strings.xml
android/res/values-ja/strings.xml
android/res/values-pl/strings.xml
android/res/values-ms/strings.xml
android/res/values-fr/strings.xml
android/res/values-ro/strings.xml
android/res/values-de/strings.xml
android/res/layout/splash.xml
android/res/values-it/strings.xml
android/res/values-es/strings.xml
android/res/values/libs.xml
android/res/values/strings.xml
android/res/values-el/strings.xml
android/res/values-et/strings.xml
android/res/values-pt-rBR/strings.xml
android/AndroidManifest.xml
android/src/org/qtproject/qt5/android/bindings/QtActivity.java
android/src/org/qtproject/qt5/android/bindings/QtApplication.java
android/src/org/kde/necessitas/ministro/IMinistro.aidl
android/src/org/kde/necessitas/ministro/IMinistroCallback.aidlwin32:CONFIG(release, debug|release): LIBS += -L$$PWD/../../../Qt5.1.0/5.1.0/android_armv7/plugins/imageformats/release/ -lqgif
else:win32:CONFIG(debug, debug|release): LIBS += -L$$PWD/../../../Qt5.1.0/5.1.0/android_armv7/plugins/imageformats/debug/ -lqgif
else:unix: LIBS += -L$$PWD/../../../Qt5.1.0/5.1.0/android_armv7/plugins/imageformats/ -lqgifINCLUDEPATH += $$PWD/../../../Qt5.1.0/5.1.0/android_armv7/plugins/imageformats
DEPENDPATH += $$PWD/../../../Qt5.1.0/5.1.0/android_armv7/plugins/imageformats
@
when I build it.. I am getting these two errors " /home/manasi/workspace/guianimation/guianimation/main.cpp:18: error: undefined reference to 'qt_static_plugin_lqgif()' " and " :-1: error: collect2: error: ld returned 1 exit status " .
I assume there is a plugin "qgif" which is not found. I tried installing it but couldnt find it. The library file libqgif.so is there in the Qt directory.
Not sure how to debug it.. can you please help me ? :)Regards,
Mansi -
QTPLUGIN is used when you want to link against a static plugin which AFAIK is not what you are doing
-
you don't need to specify them in your PRO file using the QTPLUGIN variable.
Qt automatically reads them from the plugins directory.E.g. <QT>/plugins/imageformats/qgif.dll
(exact path is depending on your Qt version)Also you need to deploy the plugins with your application (in the correct sub-folder!
-
Hello,
I am actually confused here... I assume there is a difference between plugin and a library... there is something called as libqgif.so which is a library and a plugin qgif. I think the .so file has the plugin qgif.
And yes the library is there in the same path as you mentioned.My Qt is built dynamically and im trying to use a static plugin.. is that an issue ? Not able to figure out when you say deploy plugin with application.. what do you exactly mean by that ?? can you please elaborate....
Thanks a lot in advance,
Mansi -
[quote author="mansi" date="1377834213"]
My Qt is built dynamically and im trying to use a static plugin.. is that an issue ? [/quote]
yes it is! if you want to use Qt in a static manner you must have also built Qt itself statically.
Once you've built Qt statically read this about "static plugins":http://qt-project.org/doc/qt-4.8/plugins-howto.html#static-plugins.[quote author="mansi" date="1377834213"]
Not able to figure out when you say deploy plugin with application.. what do you exactly mean by that ?? can you please elaborate....
[/quote]
This is only relevant when you deploy your application with dynamic linked libraries of course. For "deploying to windows":http://qt-project.org/doc/qt-5.0/qtdoc/deployment-windows.html for example.