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

Qt-interest Archive, May 2007
Newbee beginner problem - widgets don't show propperly


Message 1 in thread

Hello

I'm trying to write a simple widget to find out why they don't show 
correctly.

Simple::Simple (QMainWindow *parent, const char *name)
 : QMainWindow (parent, name)
{
 QGrid *grid = new QGrid (4, this, "grid");
 QPushButton *one   = new QPushButton ("&one",   grid, "one");
 QPushButton *two   = new QPushButton ("&two",   grid, "two");
 QPushButton *three = new QPushButton ("t&hree", grid, "three");
 QPushButton *quit = new QPushButton ("&Quit",  grid, "quit");
 connect (quit, SIGNAL (clicked ()), qApp, SLOT (quit()));
}

Only button one and half of button two is visable! What have I not 
understood ..?..

pls help

espen

--
 [ signature omitted ] 

Message 2 in thread

On 19.05.07 13:38:34, Espen M. Rutger wrote:
> I'm trying to write a simple widget to find out why they don't show correctly.
> 
> Simple::Simple (QMainWindow *parent, const char *name)
> : QMainWindow (parent, name)
> {
> QGrid *grid = new QGrid (4, this, "grid");
> QPushButton *one   = new QPushButton ("&one",   grid, "one");
> QPushButton *two   = new QPushButton ("&two",   grid, "two");
> QPushButton *three = new QPushButton ("t&hree", grid, "three");
> QPushButton *quit = new QPushButton ("&Quit",  grid, "quit");
> connect (quit, SIGNAL (clicked ()), qApp, SLOT (quit()));
> }
> 
> Only button one and half of button two is visable! What have I not understood 
> ..?..

How one uses QMainWindow. You don't create a layout on a QMainWindow,
rather you create it on a plain simple QWidget and then use
setCentralWidget to set the central widget of the mainwindow to this
widget.

Or if you don't need menubar,toolbar and statusbar just use a plain
QWidget	as base class.

Andreas

-- 
 [ signature omitted ] 

Message 3 in thread

Which Qt version ?  Which operating system ?

Espen M. Rutger wrote:
> Hello
>
> I'm trying to write a simple widget to find out why they don't show 
> correctly.
>
> Simple::Simple (QMainWindow *parent, const char *name)
> : QMainWindow (parent, name)
> {
> QGrid *grid = new QGrid (4, this, "grid");
> QPushButton *one   = new QPushButton ("&one",   grid, "one");
> QPushButton *two   = new QPushButton ("&two",   grid, "two");
> QPushButton *three = new QPushButton ("t&hree", grid, "three");
> QPushButton *quit = new QPushButton ("&Quit",  grid, "quit");
> connect (quit, SIGNAL (clicked ()), qApp, SLOT (quit()));
> }
>
> Only button one and half of button two is visable! What have I not 
> understood ..?..
>
> pls help
>
> espen
>
> -- 
> To unsubscribe - send a mail to qt-interest-request@xxxxxxxxxxxxx with 
> "unsubscribe" in the subject or the body.
> List archive and information: http://lists.trolltech.com/qt-interest/
>
>

--
 [ signature omitted ] 

Message 4 in thread

Just look for a second at the code... I'm sure it's Qt 3.x
After creating a grid object try calling setLayout(grid);

On May 19, 2007, at 1:00 PM, Joshua Robinson wrote:

> Which Qt version ?  Which operating system ?
>
> Espen M. Rutger wrote:
>> Hello
>>
>> I'm trying to write a simple widget to find out why they don't  
>> show correctly.
>>
>> Simple::Simple (QMainWindow *parent, const char *name)
>> : QMainWindow (parent, name)
>> {
>> QGrid *grid = new QGrid (4, this, "grid");
>> QPushButton *one   = new QPushButton ("&one",   grid, "one");
>> QPushButton *two   = new QPushButton ("&two",   grid, "two");
>> QPushButton *three = new QPushButton ("t&hree", grid, "three");
>> QPushButton *quit = new QPushButton ("&Quit",  grid, "quit");
>> connect (quit, SIGNAL (clicked ()), qApp, SLOT (quit()));
>> }
>>
>> Only button one and half of button two is visable! What have I not  
>> understood ..?..
>>
>> pls help
>>
>> espen
>>
>> -- 
>> To unsubscribe - send a mail to qt-interest-request@xxxxxxxxxxxxx  
>> with "unsubscribe" in the subject or the body.
>> List archive and information: http://lists.trolltech.com/qt-interest/
>>
>>
>
> --
> To unsubscribe - send a mail to qt-interest-request@xxxxxxxxxxxxx  
> with "unsubscribe" in the subject or the body.
> List archive and information: http://lists.trolltech.com/qt-interest/
>

--
 [ signature omitted ] 

Message 5 in thread

Hope this will help...

Simple::Simple (QMainWindow *parent, const char *name)
: QMainWindow (parent, name)
{
     myControlLayout  *myLayout = new myControlLayout(this);
    setCentralWidget(myLayout);
          OR
    setCentralWidget(new myControlLayout(this));
}

// this is your layout manager
myControlLayout::myControlLayout(QWidget *parent)
: QWidget(parent) {
    QVBoxLayout *vbl = new QVBoxLayout;  // you can use other
    Q_CHECK_PTR(vbl);
    setLayout(vbl);

QPushButton *one   = new QPushButton ("&one",   grid, "one");
QPushButton *two   = new QPushButton ("&two",   grid, "two");
QPushButton *three = new QPushButton ("t&hree", grid, "three");
QPushButton *quit = new QPushButton ("&Quit",  grid, "quit");
connect (quit, SIGNAL (clicked ()), qApp, SLOT (quit()));

    vbl->addWidget(one);
    vbl->addWidget(two);
    vbl->addWidget(three);
    vbl->addWidget(quit);
       OR
    vbl->addWidget(new QPushButton ("&Good By",  grid, "By By..."));
    show();
}

~~~~~~~~~~~


Espen M. Rutger wrote:
> Hello
>
> I'm trying to write a simple widget to find out why they don't show 
> correctly.
>
> Simple::Simple (QMainWindow *parent, const char *name)
> : QMainWindow (parent, name)
> {
> QGrid *grid = new QGrid (4, this, "grid");
> QPushButton *one   = new QPushButton ("&one",   grid, "one");
> QPushButton *two   = new QPushButton ("&two",   grid, "two");
> QPushButton *three = new QPushButton ("t&hree", grid, "three");
> QPushButton *quit = new QPushButton ("&Quit",  grid, "quit");
> connect (quit, SIGNAL (clicked ()), qApp, SLOT (quit()));
> }
>
> Only button one and half of button two is visable! What have I not 
> understood ..?..
>
> pls help
>
> espen
>
> -- 
> To unsubscribe - send a mail to qt-interest-request@xxxxxxxxxxxxx with 
> "unsubscribe" in the subject or the body.
> List archive and information: http://lists.trolltech.com/qt-interest/
>
>

--
 [ signature omitted ]