PDA

View Full Version : How to set QListWidget size MAX = QMainWindow ?



Kenneth
16th March 2007, 10:54
EngineerMainWindow::EngineerMainWindow(QWidget *parent, Qt::WFlags fl)
: QMainWindow( parent, fl )
{
//====== set main window size, title
//======main window already has layout, don't set layout
setWindowTitle( tr("Engineer Mode") );
this->setMaximumSize ( 171, 176 );

QListWidget *mList = new QListWidget( this );
QListWidgetItem *item = 0;

#if 0
//====== set widget list size
mList->setMaximumWidth ( 171 );
mList->setMinimumHeight ( 176 );
//mList->setMaximumHeight ( 176 );
#endif
#if 0
//mList->setMaximumSize ( mList->maximumSize() );
QSize se = mList->maximumSize();
qWarning()<< "max size = " << se; // ==== printf : max size = QSize(171,16777215)
mList->setMaximumSize ( se );
#endif

}

I set my QMainWindow size MaximumSize ( 171, 176 );
Then I added a QListWidget on the MainWindow,
I would like let the QListWidget Size the same as MainWindow,
But I try a lot of API of Qtopia, the ListWidget always display 60% area of the MainWindow.
Wolud you tell me why ?? Thanks !!
PS: if I set QListWidget size (171,176) first, the I get QSize will the same as my setting(171,176) ...@@'', but it displaying on the screen size that is not (171, 176),
it looks like (120, 176), the height is ok, but width is wrong...

Kumosan
16th March 2007, 11:00
You could try to use a layout. Add one to your QMainWidget and add your QListWidget. Does not matter that it is your only widget in the layout. Usually works for me.

jpn
16th March 2007, 11:02
How about setting the list widget as a central widget of the main window? See QMainWindow::setCentralWidget().

Kenneth
16th March 2007, 11:11
COOL~
Thanks~

I use QMainWindow::setCentralWidget ( QWidget * widget ) ,
it seems to be OK.:cool: