简体   繁体   中英

How to make widget never go to full screen mode in Qt?

i recently started to use qt creator to make a small program ,and i am trying to make a login screen where the user can't go full screen. i searched in the property menu ,but i couldn't find anything ,and searched the internet ,but also didn't find anything.

So you can say how to not go full screen?

i am using c++ to write the program.

You can use

QWidget::setMaximumSize(const QSize &)

to set a largest possible size on your widget.

You can find the size of the screen with the following code and then can set the max size to half of the screen size or whatever you want to:

QScreen *screen = QGuiApplication::primaryScreen();
QRect  geometry= screen->geometry();
int h= screenGeometry.height();
int w= screenGeometry.width();

from abhishek agarwal's comment, you should go to the .ui file and set the minimum value and maximum value with the same value like this

<property name="minimumSize"> 
   <size> 
    <width>900</width> 
    <height>600</height> 
   </size> 
</property> 
<property name="maximumSize"> 
  <size> 
    <width>900</width> 
    <height>600</height> 
</size> 

the full screen button will hide thus the window will not go full screen

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM