[Qt-interest] New to QT - Beginners questions

Jens Saathoff jens.saathoff at zsr-verlag.de
Wed Sep 1 14:30:31 CEST 2010


  Hi!
> Den 01-09-2010 12:23, Jens Saathoff skrev:
>>    Hi!
>>
>> I'm new to QT and want to discover it a bit. I've downloaded the version
>> 4.6.3 with QtCreator for Windows.
>> I'm not new to gui-stuff at all, so my questions in a list for short
>> answers.
>>
>> 1. I'm using QTCreator with QTDesigner to design my windows. The
>> generator generates an "ui_mainwindow.h" for example. In this header is
>> a method "setupUI()" where all the sub-components are instantiated.
>> So far so good. But how to use it? ui->mycomponent does not work at all.
>> Must i create a new pointer in my mainwindoe-header and point it to
>> ui->mycomponent in my mainwindow-constructor to call it in my other
>> mainwindow's methods?
>> Does QT remove the subcomponents from memory if the parentwindow was
>> deleted? Or is it necessary to delete every subcomponent?
>
> You need to read the designer manual:
> http://doc.qt.nokia.com/4.6/designer-manual.html
>
> Here you will see, that you have to create a widget as a container for 
> the designer stuff.
>
> Something like this:
>
> QMainWindow* window = new QMainWIndow;
> Ui::MainWIndow ui;
> ui.setupUi(window);
>
> In practice, I always subclass QMainWindow and call setupUi() from the 
> constructor.
I am doing that already. There's a misunderstanding. I know i have to 
call Setupui. How to get the components in ui-instance if i call setupui 
in the constructor of my derived mainwindow-class?
Let's say a QLabel-Instance: MyMainwindow->ui->myLabel won't work.

Do use a member for that.
Example (mainwindow.h):
private
     QLabel* thelabel;

Then in mainwindow-constructor:

ui.setupUI();
thelabel = ui.MyLabel;


What's the best method?

Do you have some example-code? The delivered qt-Examples are not useful.

For wxWidgets-GUI i don't use any GUI-Designer. Would you recommend 
using QtCreator or switch back to "design it without a GUI-Designer"?

>
>> 2. I've read about the SDK for mobile devices (Symbian, Maemo, Windows
>> Mobile). Can i just create one code-base for all and compile it for each
>> platform?
>
> In theory, yes. However, I'd say that for anything non-trivial, you 
> can't use the same GUI on all these. There is a *big* difference 
> between running Qt on a small and on a big screen.

I thought there are some preprocesser-directives like SMALLSCREEN and 
BIGSCREEN or HORIZONTAL or VERTICAL

#ifdef BIGSCREEN
     SetupBigUI();
#else
     SetupSmallUI();
#endif

Would work for a simple app (with nothing special and easy GUI) or not?


>
>> That's all. Please excuse my stupid questions. I'm new to QT. I'll buy a
>> book this week.
>
> That's probably a good idea, but there is a lot of very good 
> information in the documentation as well. Read it :)
:-)

Thank you!!!
>
> Bo Thorsen,
> Fionia Software.
>
>
>
> Eingehende eMail ist virenfrei.
> Von AVG überprüft - www.avg.de
> Version: 9.0.851 / Virendatenbank: 271.1.1/3105 - Ausgabedatum: 08/31/10 20:34:00
>


-- 

__________________________________________________________
zsr Verlag oHG
Hatter Landstr. 34
D-26209 Hatten Germany
Fon: (+49) 4481- 90 70 880
Fax: (+49) 4481- 90 70 888
Mail: info at zsr-verlag.de
Amtsgericht Oldenburg, HRA 201249
Geschäftsführer: Maik Thomas
Ust.-ID-Nr.: DE259115158

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20100901/9f0338c2/attachment.html 


More information about the Qt-interest-old mailing list