PstdEr
28th October 2013, 18:56
I am creating an application which has some widgets like display window , keypad and log window.
display window to display some external application
keypad to control application
log window to display logs
the difficulty i am facing is with layouts and window sizes
i want to see my interface look same way in minimized and maximized state , i mean
all borders of windows.
Images are attached.
Problem 1:
when in minimized state
At the right most side(between DispWin and KeyWin) and at the bottom just above the LogWin(between LogWin and DispWin), i cannot see border of MainWin(i.e Cyan color)
Problem 2:
when in maxiimized state and in minimized state
The keypad height is exceding the height of MainWin despite setting proper height.
I want to see all the borders of windows( ie Cyan color around DispWin, LogWin and NavyBlue around MainWin and KeyWin.
I tried in various ways , but could not achieve.
please help...
#define KEYPAD_WIDTH 200
#define KEYPAD_HEIGHT 700
#define LOGWINDOW_HEIGHT 80
#define MIN_WIDTH_FACTOR 240
#define MIN_HEIGHT_FACTOR 100
MainWindow::MainWindow(QWidget *parent)
: QMainWindow(parent)
{
int x_c, y_c, screen_width,screen_height;
int display_window_width,display_window_height;
ServerWin = new QWidget;
MainWin = new QWidget;
DispWin = new QWidget;
LogWin = new QWidget;
KeyWin = new QWidget;
QHBoxLayout *Mlayout = new QHBoxLayout;
QVBoxLayout *Dlayout = new QVBoxLayout;
QDesktopWidget *D = new QDesktopWidget;
QRect rect = D->geometry();
rect.getRect(&x_c,&y_c,&screen_width,&screen_height);
qDebug()<<"x="<<x_c<<"y="<<y_c<<"s_w="<<screen_width<<"s_h="<<screen_height<<endl;
display_window_width = screen_width - MIN_WIDTH_FACTOR - KEYPAD_WIDTH;
display_window_height = screen_height- MIN_HEIGHT_FACTOR - LOGWINDOW_HEIGHT;
setMinimumSize(screen_width - MIN_WIDTH_FACTOR,screen_height-MIN_HEIGHT_FACTOR);
setMaximumSize(screen_width, screen_height);
//setSizePolicy(QSizePolicy::Expanding,QSizePolicy:: Expanding);
ServerWin->setMinimumSize(screen_width - MIN_WIDTH_FACTOR,screen_height-MIN_HEIGHT_FACTOR);
ServerWin->setMaximumSize(screen_width, screen_height);
setCentralWidget(ServerWin);
ServerWin->setSizePolicy(QSizePolicy::Expanding,QSizePolicy:: Expanding);
setPalette(QPalette(QColor(0,0,128,255)));//Navy Blue
setAutoFillBackground(true);
MainWin->setPalette(QPalette(QColor(0,255,255,255)));//Cyan
MainWin->setAutoFillBackground(true);
Dlayout->addWidget(DispWin);
DispWin->setPalette(QPalette(QColor( 230,230,250,255)));//Lavender
DispWin->setAutoFillBackground(true);
Dlayout->setSpacing(1);
DispWin->setMinimumSize(display_window_width,display_window _height);
Dlayout->addWidget(LogWin);
LogWin->setPalette(QPalette(QColor(148,0,211,255)));//Dark Violet
LogWin->setAutoFillBackground(true);
LogWin->setMinimumSize(display_window_width,LOGWINDOW_HEIG HT);
MainWin->setLayout(Dlayout);
KeyWin->setPalette(QPalette(QColor( 238,130,238,255)));//Violet
KeyWin->setAutoFillBackground(true);
//QWidget* keypad = new QWidget;
//QHBoxLayout *vLay = new QHBoxLayout;
//keypad->setLayout(vLay);
//KeyWin->setFixedSize(KEYPAD_WIDTH,KEYPAD_HEIGHT+20);
//KeyWin->setFixedSize(KEYPAD_WIDTH,(display_window_height+L OGWINDOW_HEIGHT/*+MIN_HEIGHT_FACTOR*/));
//KeyWin->setFixedSize(KEYPAD_WIDTH,display_window_height+LO GWINDOW_HEIGHT /*(screen_height-MIN_HEIGHT_FACTOR+display_window_height-100)*/);
KeyWin->setFixedSize(KEYPAD_WIDTH,DispWin->height()+LogWin->height() /*(screen_height-MIN_HEIGHT_FACTOR+display_window_height-100)*/);
//KeyWin->setMinimumSize(KEYPAD_WIDTH,(screen_height-MIN_HEIGHT_FACTOR));
//vLay->addWidget(KeyWin);
vLay->setContentsMargins(0,0,0,0);
Mlayout->addWidget(MainWin);
Mlayout->setSpacing(1);
Mlayout->addWidget(KeyWin);
ServerWin->setLayout(Mlayout);
}
display window to display some external application
keypad to control application
log window to display logs
the difficulty i am facing is with layouts and window sizes
i want to see my interface look same way in minimized and maximized state , i mean
all borders of windows.
Images are attached.
Problem 1:
when in minimized state
At the right most side(between DispWin and KeyWin) and at the bottom just above the LogWin(between LogWin and DispWin), i cannot see border of MainWin(i.e Cyan color)
Problem 2:
when in maxiimized state and in minimized state
The keypad height is exceding the height of MainWin despite setting proper height.
I want to see all the borders of windows( ie Cyan color around DispWin, LogWin and NavyBlue around MainWin and KeyWin.
I tried in various ways , but could not achieve.
please help...
#define KEYPAD_WIDTH 200
#define KEYPAD_HEIGHT 700
#define LOGWINDOW_HEIGHT 80
#define MIN_WIDTH_FACTOR 240
#define MIN_HEIGHT_FACTOR 100
MainWindow::MainWindow(QWidget *parent)
: QMainWindow(parent)
{
int x_c, y_c, screen_width,screen_height;
int display_window_width,display_window_height;
ServerWin = new QWidget;
MainWin = new QWidget;
DispWin = new QWidget;
LogWin = new QWidget;
KeyWin = new QWidget;
QHBoxLayout *Mlayout = new QHBoxLayout;
QVBoxLayout *Dlayout = new QVBoxLayout;
QDesktopWidget *D = new QDesktopWidget;
QRect rect = D->geometry();
rect.getRect(&x_c,&y_c,&screen_width,&screen_height);
qDebug()<<"x="<<x_c<<"y="<<y_c<<"s_w="<<screen_width<<"s_h="<<screen_height<<endl;
display_window_width = screen_width - MIN_WIDTH_FACTOR - KEYPAD_WIDTH;
display_window_height = screen_height- MIN_HEIGHT_FACTOR - LOGWINDOW_HEIGHT;
setMinimumSize(screen_width - MIN_WIDTH_FACTOR,screen_height-MIN_HEIGHT_FACTOR);
setMaximumSize(screen_width, screen_height);
//setSizePolicy(QSizePolicy::Expanding,QSizePolicy:: Expanding);
ServerWin->setMinimumSize(screen_width - MIN_WIDTH_FACTOR,screen_height-MIN_HEIGHT_FACTOR);
ServerWin->setMaximumSize(screen_width, screen_height);
setCentralWidget(ServerWin);
ServerWin->setSizePolicy(QSizePolicy::Expanding,QSizePolicy:: Expanding);
setPalette(QPalette(QColor(0,0,128,255)));//Navy Blue
setAutoFillBackground(true);
MainWin->setPalette(QPalette(QColor(0,255,255,255)));//Cyan
MainWin->setAutoFillBackground(true);
Dlayout->addWidget(DispWin);
DispWin->setPalette(QPalette(QColor( 230,230,250,255)));//Lavender
DispWin->setAutoFillBackground(true);
Dlayout->setSpacing(1);
DispWin->setMinimumSize(display_window_width,display_window _height);
Dlayout->addWidget(LogWin);
LogWin->setPalette(QPalette(QColor(148,0,211,255)));//Dark Violet
LogWin->setAutoFillBackground(true);
LogWin->setMinimumSize(display_window_width,LOGWINDOW_HEIG HT);
MainWin->setLayout(Dlayout);
KeyWin->setPalette(QPalette(QColor( 238,130,238,255)));//Violet
KeyWin->setAutoFillBackground(true);
//QWidget* keypad = new QWidget;
//QHBoxLayout *vLay = new QHBoxLayout;
//keypad->setLayout(vLay);
//KeyWin->setFixedSize(KEYPAD_WIDTH,KEYPAD_HEIGHT+20);
//KeyWin->setFixedSize(KEYPAD_WIDTH,(display_window_height+L OGWINDOW_HEIGHT/*+MIN_HEIGHT_FACTOR*/));
//KeyWin->setFixedSize(KEYPAD_WIDTH,display_window_height+LO GWINDOW_HEIGHT /*(screen_height-MIN_HEIGHT_FACTOR+display_window_height-100)*/);
KeyWin->setFixedSize(KEYPAD_WIDTH,DispWin->height()+LogWin->height() /*(screen_height-MIN_HEIGHT_FACTOR+display_window_height-100)*/);
//KeyWin->setMinimumSize(KEYPAD_WIDTH,(screen_height-MIN_HEIGHT_FACTOR));
//vLay->addWidget(KeyWin);
vLay->setContentsMargins(0,0,0,0);
Mlayout->addWidget(MainWin);
Mlayout->setSpacing(1);
Mlayout->addWidget(KeyWin);
ServerWin->setLayout(Mlayout);
}