PDA

View Full Version : calendar button in a QtableView or something



spiderman3000p
8th January 2011, 03:18
Hi everyone!!!

First, i have to say that i don't know if i have choosen the rigth title for this post.

Well, my "problem" is the next one:


i got a window to edit some tables from my database. I use a QSqlTableModel and a QTableView to show it. There is some tables that have a date field in them. And what i want to achieve is that the date can be entered with a widget tha pops up when the users click it (like happens in the web).

My idea is to insert a button into that field in every record or row in my Table. There is so many calendars done with javascript. and i gat a few of them. I thought maybe i could use java script to achieve this.

I hope that some body in this forum can help me. Maybe some body made it, may be some body made it with another approach. but i need some ideas or suggestions.

in conlusion, i got this:

http://www.fileden.com/files/2007/6/13/1173901/Dibujo2.jpg


and y want to include some thing like this:

http://www.fileden.com/files/2007/6/13/1173901/Dibujo3.jpg

Any i dea will be appreciated!! :thumbsup: :thumbsup: :thumbsup:

im waiting for some answers. So many thanks in advance, sorry for my bad english.



In spanish:

poseo una ventana para editar tablas de mi base de datos. Existen algunas tablas que poseen un campo fecha. y lo que quiero lograr es que en lugar de que la fecha se introduzca manualmente (propenso a ser una fecha inválida), quiero crear un boton alli dentro de ese line edit o algún método similar que traiga un calendario emergente (de esos que vemos mucho en la web). Busque en internet y existen muchos calendarios ya implementados en JavaScript.

algo asi es lo que tengo:

http://www.fileden.com/files/2007/6/13/1173901/Dibujo.jpg

y quiero ponerle algo como esto:

http://www.fileden.com/files/2007/6/13/1173901/Dibujo3.jpg

pensaba en usar un QCalendarWidget y estarÃ*a bien..si no fuera por el hecho de que realmente necesito que se vea flotante como el de la web y no en una ventana a parte. Por eso pensé en el JavaScript.

Bueno al final, si alguien tiene idea de cómo hacerlo o conoce otro método para lograrlo por favor, agradeceré su respuesta aquÃ*.

Muchas gracias de antemano.

:thumbsup: :thumbsup: :thumbsup:

Lykurg
8th January 2011, 09:52
Hola!

More Spanish is not possible ;) First: I haven't done it myself, but I would go for a custom delegate. For the button reimp the delegates paint methode. As for the pop up you have to create an editor. See the createEditor() function. Also read the section "Model/View Programming" in the docs.

Unfortunatelly there is no out of the box solution for you.

javimoya
8th January 2011, 10:59
--- in english ---

You cannot create a calendar widget with javascript...
You could create a calendar in javascript if you use a qwebview to show your data... but you are using a qtableview...
If you want to add a button in a qtableview is quite easy... just google it... there are many examples out there.
Anyway I don't understand the meaning of a "floating" calendar.
Just put a button... and when the user click on the button show a qcalendarwidget in the position you want !
If you need a "movable" calendar... there are many options... for exampe : just create a dialog with a qcalendarwidget inside...

Regards

--- in spanish ---
Lo de que esté codificado el calendario en javascript olvidate.
Sólo podrÃ*as hacerlo si usas qwebview ... presentar allÃ* la lista y lo que quieras en html y javascript... en lugar de usar una qtableview...

A mi entender mucho mas trabajo.

Lo de agregar un botón o cualquier widget en una columna es fácil... busca por aquÃ* o en google... hay muchos ejemplos.
No entiendo la necesidad de que el calendario sea "flotante"... No aporta nada...
Simplemente pon un botón, y cuando el usuario pulse en el botón que se muestre un qcalendarwidget !!
Si "con flotante" te refieres a que el usuario pueda moverlo por la ventana... pues create un dialog flotante con un calendario dentro... y que el botón llame a ese dialog.

Saludos

spiderman3000p
8th January 2011, 15:19
So many thanks to you All. jajajaja "more is spanish is imposible"..it sounds great for Zona Qt (the spanish forum, where i am from).

Well, friends all oyur answer are so important to me, that say thanks to you is...a little think.

thanks again.

SixDegrees
8th January 2011, 16:01
This might help. (http://doc.qt.nokia.com/4.5/qcalendarwidget.html)

Or this. (http://doc.qt.nokia.com/4.5/qdatetimeedit.html) This one will automatically pop up a calendar widget if the right flags are set.

spiderman3000p
8th January 2011, 17:47
This might help. (http://doc.qt.nokia.com/4.5/qcalendarwidget.html)

Or this. (http://doc.qt.nokia.com/4.5/qdatetimeedit.html) This one will automatically pop up a calendar widget if the right flags are set.

this can really help me. thanks for it.

But my problen now is how to insert this date edit into a field of my QtableView...???
:confused::confused::confused::confused:

what method i need to use or what method i need to reimp???