PDA

View Full Version : toolbox



mickey
13th April 2006, 15:03
hi, I inserted a toolBox from designer in MainForm; now from mainForm I'd like to control its width and do something like this:


//paintGL()
int widthWidget = this->width();
mainForm->toolBox->setMinimumWidth(widthWidget/4);
mainForm->toolBox->setMaximumWidth(widthWidget/4);

(but it doesn't work, when I enlarge window app maximumToolBoxWidth block the window app width too...)
I need set width of toolBox 1/4 of Widget (and when I resize my window app toolBox should be maintain 1/4 width)
How can I do this? Thanks

zlatko
13th April 2006, 16:37
Have 2 choice :
- reinplement resizeEvent for your main window, and set toolbox size there
- use layouts(better way)

wysota
13th April 2006, 17:08
You can use stretchFactors to manipulate widget size relative to its siblings in a layout.

mickey
13th April 2006, 20:58
Ok, but I'd like avoid this; is there a way to retrieve the screen resolution (from QT)? Thanks

wysota
13th April 2006, 21:24
QDesktopWidget

mickey
13th April 2006, 22:09
Thanks, this seem works; but return height 704 instead of 768; the task Bar or window isn't included in height...How can I do? Thanks


QDesktopWidget* qw;
QRect rect = qw->availableGeometry(0);
std::cout << "Screen Width: " << rect.width() << endl;
std::cout << "Screen Height: " << rect.height() << endl;

zlatko
14th April 2006, 12:43
Use QScreen instead QDesktopWidget

wysota
14th April 2006, 12:54
Thanks, this seem works; but return height 704 instead of 768; the task Bar or window isn't included in height...How can I do?



QDesktopWidget* qw;
QRect rect = qw->screenGeometry(0);
std::cout << "Screen Width: " << rect.width() << endl;
std::cout << "Screen Height: " << rect.height() << endl;

The docs say:


const QRect & QDesktopWidget::availableGeometry ( int screen = -1 ) const
Returns the available geometry of the screen with index screen. What is available will be subrect of screenGeometry() based on what the platform decides is available (for example excludes the Dock and Menubar on Mac OS X, or the taskbar on Windows).
See also screenNumber() and screenGeometry().