Window sizes and Layouts Problem



  • 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.

    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 dont know how to attach images here other wie i would have attached.
    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="&lt;&lt;x_c&lt;&lt;"y="&lt;&lt;y_c&lt;&lt;"s_w="&lt;&lt;screen_width&lt;&lt;"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_HEIGHT);
    
    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+LOGWINDOW_HEIGHT/*+MIN_HEIGHT_FACTOR*/));
    //KeyWin->setFixedSize(KEYPAD_WIDTH,display_window_height+LOGWINDOW_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);
    

    }

    @



  • I know , it may be difficult or rather boring to see this kind of post, but i have tried in various ways, yet could not get what i wanted.

    I will explain in simple terms , so that i might get some reply.

    what i want is to display all windows with the borders no matter they are in MinimumSize or MaximumSize.

    the problem here is when it is in MinimumSize the windows DispWin, and LogWin are not completely seen, the KeyWin overlaps these two windows.
    when Maximized every thing is seen with border.

    I want the same look that shows in MinimumSize state even if the window is in MinimumSize, ofcourse the windows are small , but should be able to see full windows.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.