You are not logged in.

1

Thursday, May 12th 2005, 10:58am

All widgets are declared 'public', why?

hi,

I am using Qt Designer to create a new widget. I just added some QLabels on the Form, but all these sub widgets are declared as 'public' in the generated header file. My question is how to change 'public' to 'private' in Qt Designer.

thanks in advance.

  • "wysota" is male

Posts: 4,276

Location: Warsaw, POLAND

  • Send private message

2

Thursday, May 12th 2005, 11:16am

RE: All widgets are declared 'public', why?

Subclass the widget. They are declared as public so that you can access them from outside the class, for example to make signal/slot connections.

3

Thursday, May 12th 2005, 11:29am

RE: All widgets are declared 'public', why?

hi wysota,

thank you for reply. But I don't want to do so, for example, I have a QLineEdit 'studentName', later I will create get/set methods to access it instead of direct accessing this widget.

Is there any way to change 'public' to 'private' in Qt Designer?

4

Friday, May 13th 2005, 8:35am

RE: All widgets are declared 'public', why?

Quoted

Is there any way to change 'public' to 'private' in Qt Designer?

There isn't in QT Designer.

You should subclass it as Wysota suggested to you. So you have to use code to accomplish this.

I don't know exactly what you want to accomplish, but here are some suggestions :
You could use a private member variable with public functions to set and retrieve it. If you don't need the lineedit anymore, you can delete it.

You could set the read only property of the lineedit to true. so your users can't change it.

Cheers

This post has been edited 1 times, last edit by "Everall" (May 13th 2005, 8:42am)