Qt-interest Archive, March 2002
QObject, QString, SLOT(),
Message 1 in thread
Hi there,
I would like to implement something like the code below. I have got only
a string of an existing public slot function e.g. "printing()" How can I
convert this to "QObject *receiver" so that the moc recognize that this is
a function. In my example the compiler cant connect it to the function printing().
Any solutions?
Thanks for helping
Juergen
class A
{
Q_OBJECT
public:
A();
~A();
public slots:
void printing(){ cout << "Hello" << endl; }
void my_connect(QString function = "printing()");
private:
QMenuBar *p_menubar;
QPopupMenu *p_menu;
};
//-----------------------------------------------------------------------------
A::A()
{
p_menubar = new QMenuBar();
p_menu = new QPopupMenu();
p_menubar->insertItem("Testing", p_menu);
}
//----------------------------------------------------------------------------
void A::my_connect( QString function )
{
p_menu->insertItem( "Print", this,
SLOT( function ) ); //Problem: How
can I make from a string a qobject?
}
Genug gewartet? sunrise ADSL: schneller im Internet.
http://www.sunrise.ch/de/internet/int_ads.asp
Message 2 in thread
juergen.messerer@freesurf.ch wrote:
????
What do you actually want to do?
Please be more precise, Thank's.
/G
> Hi there,
> I would like to implement something like the code below. I have got only
> a string of an existing public slot function e.g. "printing()" How can I
> convert this to "QObject *receiver" so that the moc recognize that this is
> a function. In my example the compiler cant connect it to the function printing().
> Any solutions?
>
> Thanks for helping
> Juergen
>
> class A
> {
> Q_OBJECT
>
> public:
> A();
> ~A();
> public slots:
> void printing(){ cout << "Hello" << endl; }
> void my_connect(QString function = "printing()");
> private:
> QMenuBar *p_menubar;
> QPopupMenu *p_menu;
> };
> //-----------------------------------------------------------------------------
> A::A()
> {
> p_menubar = new QMenuBar();
> p_menu = new QPopupMenu();
> p_menubar->insertItem("Testing", p_menu);
> }
> //----------------------------------------------------------------------------
> void A::my_connect( QString function )
> {
> p_menu->insertItem( "Print", this,
> SLOT( function ) ); //Problem: How
> can I make from a string a qobject?
> }
>
> Genug gewartet? sunrise ADSL: schneller im Internet.
> http://www.sunrise.ch/de/internet/int_ads.asp
>
> --
> List archive and information: http://qt-interest.trolltech.com
--
[ signature omitted ]
Message 3 in thread
I have a xml-file with information for creating a menubar. Now when I´m parsing
that file I will get the information of the items (the name which is displayed,
the function name, the hotkey and the icon).
Everything works fine except the part with the function.
Do you have any clue how I can handel this?
How can I make a QObject * from QString?
Thanks
Juergen
>-- Original Message --
>Date: Sun, 03 Mar 2002 17:27:42 +0200
>From: Greger Haga <gregerhaga@yahoo.com>
>To: juergen.messerer@freesurf.ch
>CC: qt-interest@trolltech.com
>Subject: Re: QObject, QString, SLOT(),
>
>
>
>juergen.messerer@freesurf.ch wrote:
>
>????
>What do you actually want to do?
>Please be more precise, Thank's.
>
>/G
>
>> Hi there,
>> I would like to implement something like the code below. I have got only
>> a string of an existing public slot function e.g. "printing()" How can
>I
>> convert this to "QObject *receiver" so that the moc recognize that this
>is
>> a function. In my example the compiler cant connect it to the function
>printing().
>> Any solutions?
>>
>> Thanks for helping
>> Juergen
>>
>> class A
>> {
>> Q_OBJECT
>>
>> public:
>> A();
>> ~A();
>> public slots:
>> void printing(){ cout << "Hello" << endl; }
>> void my_connect(QString function = "printing()");
>> private:
>> QMenuBar *p_menubar;
>> QPopupMenu *p_menu;
>> };
>> //-----------------------------------------------------------------------------
>> A::A()
>> {
>> p_menubar = new QMenuBar();
>> p_menu = new QPopupMenu();
>> p_menubar->insertItem("Testing", p_menu);
>> }
>> //----------------------------------------------------------------------------
>> void A::my_connect( QString function )
>> {
>> p_menu->insertItem( "Print", this,
>> SLOT( function ) ); //Problem:
How
>> can I make from a string a qobject?
>> }
>>
>> Genug gewartet? sunrise ADSL: schneller im Internet.
>> http://www.sunrise.ch/de/internet/int_ads.asp
>>
>> --
>> List archive and information: http://qt-interest.trolltech.com
>
>--
>Greger Haga
>http://www.geocities.com/gregerhaga/pres/index.html
>Winners never quit, quitters never win [Unknown]
>
>
>
>
>
>
Genug gewartet? sunrise ADSL: schneller im Internet.
http://www.sunrise.ch/de/internet/int_ads.asp
Message 4 in thread
Hi,
when you look in qobjectdefs.h you see that the SIGNAL and SLOT macros expand
their parameter to a string that is preceded by a digit, 1 for a slot and 2
for a signal. So if you have a QString object myString and want to convert it
to something suitable for the connect function as a slot do something like
this:
QString slotString("1");
slotString += myString;
connect(pSender, SIGNAL(something()), slotString.latin1());
As this is undocumented, I think it's a pretty dangerous approach though.
greetings,
P.J.
Am Sonntag, 3. März 2002 15:48 schrieb juergen.messerer@freesurf.ch:
> Hi there,
> I would like to implement something like the code below. I have got only
> a string of an existing public slot function e.g. "printing()" How can I
> convert this to "QObject *receiver" so that the moc recognize that this is
> a function. In my example the compiler cant connect it to the function
> printing(). Any solutions?
>
> Thanks for helping
> Juergen
>
--
[ signature omitted ]
Message 5 in thread
Hello
In my Qt-based Windows program I need to change the geometry (width
and height) of scroll bars in QTable object.
QTable object has an appropriate functions setHBarGeometry() and
setVBarGeometry() to do that.
When I used Qt 2.2.4 all worked fine.
But after porting the code to Qt 3.0.1 I found that there are some
stranges in the behaviour of scrollbars.
So, now the horizontal scrollbar change only its horizontal size but
refuses to resize vertically. The vertical scrollbar resizes
vertically but don't want to change its horizontal size. Who'll help
me to work it out?
Sincerely yours,
Dyuk
Here is a simple example of overloaded QTable object.
class QQTable : public QTable
{
public:
QQTable(int ncols, int nrows)
: QTable(ncols, nrows) {}
protected:
virtual void setHBarGeometry(QScrollBar& hbar, int x, int y, int w, int h)
{
QTable::setHBarGeometry(hbar, x, y, 50, 30);
/*changes its width but doesn't change its height! */
}
virtual void setVBarGeometry(QScrollBar& vbar, int x, int y, int w, int h)
{
QTable::setVBarGeometry(vbar, x, y, 30, 50);
/*changes its height but doesn't change its width! */
}
};
Message 6 in thread
Hi P.J.
I found that out too yesterday. It works very well. The question is, are
the
#define SLOT(a) "1""a"
or
#define SLOT(a) "1"#"a"
the same under Windows and MAC-OS X?
Thanks anyway.
I will follow that way.
Juergen
>-- Original Message --
>From: "P.J. Meisch" <pjmeisch@web.de>
>To: qt-interest@trolltech.com
>Subject: Re: QObject, QString, SLOT(),
>Date: Sun, 3 Mar 2002 23:08:24 +0100
>Reply-To: pjmeisch@web.de
>
>
>Hi,
>
>when you look in qobjectdefs.h you see that the SIGNAL and SLOT macros expand
>
>their parameter to a string that is preceded by a digit, 1 for a slot and
>2
>for a signal. So if you have a QString object myString and want to convert
>it
>to something suitable for the connect function as a slot do something like
>
>this:
>
>QString slotString("1");
>slotString += myString;
>connect(pSender, SIGNAL(something()), slotString.latin1());
>
>As this is undocumented, I think it's a pretty dangerous approach though.
>
>greetings,
>
>P.J.
>
>
>Am Sonntag, 3. März 2002 15:48 schrieb juergen.messerer@freesurf.ch:
>> Hi there,
>> I would like to implement something like the code below. I have got only
>> a string of an existing public slot function e.g. "printing()" How can
>I
>> convert this to "QObject *receiver" so that the moc recognize that this
>is
>> a function. In my example the compiler cant connect it to the function
>> printing(). Any solutions?
>>
>> Thanks for helping
>> Juergen
>>
>
>--
>------------------------------------------
>P.J. Meisch
>pjmeisch@web.de
>------------------------------------------
>
>--
>List archive and information: http://qt-interest.trolltech.com
Genug gewartet? sunrise ADSL: schneller im Internet.
http://www.sunrise.ch/de/internet/int_ads.asp