possible to connect defined signals(available in Qt designer) to custom slots...?
Hi to all, :)
I am having a doubt with regards to signals and slots... I was trying to connect spinboxes to the QCalendarWidget in Qt Designer (for user to edit the date, month and year) when I realise that the QCalendarWidget only has the following public slots...
Public Slots
void setCurrentPage ( int year, int month )
void setDateRange ( const QDate & min, const QDate & max )
void setSelectedDate ( const QDate & date )
void showNextMonth ()
void showNextYear ()
void showPreviousMonth ()
void showPreviousYear ()
void showSelectedDate ()
void showToday ()
19 public slots inherited from QWidget
1 public slot inherited from QObject
So does it mean that i cannot connect the signal <void valueChanged ( int i )> of the QSpinBox to any of the slots (in Qt Designer) for the purpose of date/month/year editing? In that case, am I left with the only way, which is creating my own calendar widget with my own slots and connecting them(in code)?:eek: Or are there any better way out?
Re: possible to connect defined signals(available in Qt designer) to custom slots...?
Yes, you won't be able to connect to those slots directly in Designer. But you are using the widgets inside some form that will be put into some real widget that you'll have to create. You can implement custom slots for it and manipulate the calendar widget from within there - no need to subclass QCalendarWidget.
Re: possible to connect defined signals(available in Qt designer) to custom slots...?
hihi again... :) tried doing it... so far I have only the .h file and it already has a weird error...
here's the connectcalcombox.h and the error below... in the whole .pro file, I have 5 files, main.cpp, mainframe.cpp, mainframe.h, connectcalcombox.h and .cpp(empty), and a Qt Ui file, named mainframe. The main, mainframe files are there by default when I create a new project.
Code:
#ifndef __CONNECTCALCOMBOX_H__
#define __CONNECTCALCOMBOX_H__
#include <QWidget>
// place your code here
class ConnectCalCombox
: public QWidget{
Q_OBJECT
public:
ConnectCalCombox();
private slots:
void dayDateChanged();
void mthDateChanged();
void yrDateChanged();
void minTimeChanged();
void hrTimeChanged();
private:
}
#endif // __CONNECTCALCOMBOX_H__
../../HMIDeveloper/Qt/include/QtCore/../../src/corelib/tools/qhash.h:51: error: `QtValidLicenseForCoreModule' does not name a type
mingw32-make[1]: Leaving directory `C:/HmiProject/omg'
mingw32-make[1]: *** [build\host\connectcalcombox.o] Error 1
mingw32-make: *** [release] Error 2
the error is gone when i comment out the whole part from
"class ConnectCalCombox : public QWidget" onwards... Anyone can point out my problem? >.<
Many thanks in advance. :)
Re: possible to connect defined signals(available in Qt designer) to custom slots...?
Which version of Qt are you using?
Re: possible to connect defined signals(available in Qt designer) to custom slots...?
Currently using Qt 4. :)
and there's another doubt i want to find out... if i want to set the choices in the combobox, i am not sure what to put in the 'xxx' part...
dayDateCombobox->addItem(tr("01", xxx);
i want to make it such that the selection in combo box will set the correct date in the QCalendar widget... How do i go abt doing this? :confused:
Re: possible to connect defined signals(available in Qt designer) to custom slots...?
Re: possible to connect defined signals(available in Qt designer) to custom slots...?
Re: possible to connect defined signals(available in Qt designer) to custom slots...?
The class declaration is missing ending semi-colon:
Code:
class ConnectCalCombox
{
...
}; // <---
Re: possible to connect defined signals(available in Qt designer) to custom slots...?
speaking of signals and slots.... can i connect my custom signals of a different class to the custom slots of a different class...??
Re: possible to connect defined signals(available in Qt designer) to custom slots...?
Quote:
Originally Posted by
rick_st3
speaking of signals and slots.... can i connect my custom signals of a different class to the custom slots of a different class...??
Yes, if these 2 classes are derived from QObject (or from something, which is based on QObject).
QObject::connect(<ptr to signaling class>, SIGNAL( someSignal() ), <ptr to slot class>, SLOT( someSlot() ) );
Re: possible to connect defined signals(available in Qt designer) to custom slots...?
actually i tried connecting two classes through custom signals and custom slots, one class was inheriting QWidget and the other was inheriting QGLWidget... but the connection was not working... now,is such a connection possible...??? if no please suggest some other alternative... thanks...
Re: possible to connect defined signals(available in Qt designer) to custom slots...?
Quote:
Originally Posted by
rick_st3
actually i tried connecting two classes through custom signals and custom slots, one class was inheriting QWidget and the other was inheriting QGLWidget... but the connection was not working... now,is such a connection possible...??? if no please suggest some other alternative... thanks...
Yes, it is possible. Just make sure that both class declarations contain required Q_OBJECT macro and that you declare signals and slots properly. Take a look at the debug output. QObject::connect() outputs a detailed warning when it fails to establish signal-slot connection.
Re: possible to connect defined signals(available in Qt designer) to custom slots...?