Trolltech Home | Qt-interest Home | Recent Threads | All Threads | Author | Date
All threads index page 5

Qt-interest Archive, March 2007
access class related ui namespace from outside


Message 1 in thread

hi all

I'm porting a large app to Qt4. I have a lot of files ported to the new ui
system. Let's have an example:

class Foo : public QWidget, Ui::Foo
{
   blah // constructor, setupUi(this) etc.
};

and in the other file:

class Prefs : public QDialog
{
...
private:
   Foo f;
}

void Prefs::loadFoo()
{
   f->myEditWidget->setText("blah");
...
}

the compiler exists with error:
/home/pvanek/135/Scribus/scribus/ui_tabgeneral.h: In member function âvoid
Preferences::updatePreferences()â:
/home/pvanek/135/Scribus/scribus/ui_tabgeneral.h:49: error: âQSpinBox*
Ui_TabGeneral::GFsizeâ is inaccessible
/home/pvanek/135/Scribus/scribus/prefs.cpp:340: error: within this context

how I can access the Ui namespace? I do not want to update thousands of
lines with sed or my poor hands to use Ui::Foo as a public member accessing
its widgets with "f.ui->myEditWidget". Is there any way to do it?

all the best
Petr Vanek

--
 [ signature omitted ] 

Message 2 in thread

Hi,

Petr Vanek wrote:
> I'm porting a large app to Qt4. I have a lot of files ported to the new ui
> system. Let's have an example:
> 
> class Foo : public QWidget, Ui::Foo
> {
>    blah // constructor, setupUi(this) etc.
> };
> 
> and in the other file:
> 
> class Prefs : public QDialog
> {
> ...
> private:
>    Foo f;
> }
> 
> void Prefs::loadFoo()
> {
>    f->myEditWidget->setText("blah");
> ...
> }
> 
> the compiler exists with error:
> /home/pvanek/135/Scribus/scribus/ui_tabgeneral.h: In member function âvoid
> Preferences::updatePreferences()â:
> /home/pvanek/135/Scribus/scribus/ui_tabgeneral.h:49: error: âQSpinBox*
> Ui_TabGeneral::GFsizeâ is inaccessible
> /home/pvanek/135/Scribus/scribus/prefs.cpp:340: error: within this context
> 
> how I can access the Ui namespace? I do not want to update thousands of
> lines with sed or my poor hands to use Ui::Foo as a public member accessing
> its widgets with "f.ui->myEditWidget". Is there any way to do it?

I'm assuming Foo is a private implementation class; if this is the case, 
why not publicly inherit from Ui::Foo and all should be well. Or did I 
miss something...

Tim

--
 [ signature omitted ] 

Message 3 in thread

Tim Dewhirst wrote:
> I'm assuming Foo is a private implementation class; if this is the case,
> why not publicly inherit from Ui::Foo and all should be well. Or did I
> miss something...

OMG. How I can be so much stupid?!
You are absolutely right.

Now I can write an article: "How to became an idiot in three minutes" or
something.

Thanks a lot
p.

--
 [ signature omitted ]