Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. How dose the qss influence the size of the QPushbutton
Qt 6.12 LTS is out! See what's new in the release blog

How dose the qss influence the size of the QPushbutton

Scheduled Pinned Locked Moved Unsolved General and Desktop
3 Posts 2 Posters 1.0k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • nicker playerN Offline
    nicker playerN Offline
    nicker player
    wrote on last edited by nicker player
    #1

    I've created a Pushbutton by inputing nothing,I just want to using the qss file to deside the button size.How would I do ?
    I tried to using the width,max-width,image or background-image of the qss grammar.
    But in fact its hard to understand which is the major factor to deside the fact width and height of the pushbutton.
    The api on the official website is hard to understand.

    QPushButton[ui_type="button_icon"]
    {
        /*background-color: #004AA9; 
    	padding:3px;
    	text-align:right;*/ 
    	max-width:126px;
    	max-height:28px;/**/
        image:url(:/img/img/img_back.png);
    	background-color: rgba(0,0,0,0);
        background-repeat:no-repeat;
    }
    
    QPushButton[ui_type="button_icon"]:hover{
    	/*padding:3px;
    	text-align:right; 
    	*/
    	max-width:126px;
    	max-height:36px;
        image:url(:/img/img/img_back.png);
    	background-color: rgba(0,0,0,120);
        background-position: center;
        background-origin: content;
        background-repeat:no-repeat;
        border:1px solid #D4D6D9;
    }
    
    JonBJ 1 Reply Last reply
    0
    • nicker playerN nicker player

      I've created a Pushbutton by inputing nothing,I just want to using the qss file to deside the button size.How would I do ?
      I tried to using the width,max-width,image or background-image of the qss grammar.
      But in fact its hard to understand which is the major factor to deside the fact width and height of the pushbutton.
      The api on the official website is hard to understand.

      QPushButton[ui_type="button_icon"]
      {
          /*background-color: #004AA9; 
      	padding:3px;
      	text-align:right;*/ 
      	max-width:126px;
      	max-height:28px;/**/
          image:url(:/img/img/img_back.png);
      	background-color: rgba(0,0,0,0);
          background-repeat:no-repeat;
      }
      
      QPushButton[ui_type="button_icon"]:hover{
      	/*padding:3px;
      	text-align:right; 
      	*/
      	max-width:126px;
      	max-height:36px;
          image:url(:/img/img/img_back.png);
      	background-color: rgba(0,0,0,120);
          background-position: center;
          background-origin: content;
          background-repeat:no-repeat;
          border:1px solid #D4D6D9;
      }
      
      JonBJ Offline
      JonBJ Offline
      JonB
      wrote on last edited by
      #2

      @nicker-player said in How dose the qss influence the size of the QPushbutton:

      tried to using the width,max-width,image or background-image of the qss grammar.

      And what happened with this code? Did any of the properties apply or none? In the hover or non-hover case? Would changing the maximum height of this button have any effect? Did you try height before trying max-height?

      1 Reply Last reply
      0
      • nicker playerN Offline
        nicker playerN Offline
        nicker player
        wrote on last edited by
        #3

        For example,the width and the height of the image named img_back.png is 72X28,but when I put these codes into the project.It may not work ,the image in fact always has a scale cause the button width and height.
        I just dont know the scale factor or the ohter factors to influence the button size.
        I thought there would be some guide codes to tell me how to write the right and effecient codes.

        1 Reply Last reply
        0

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt
        • Unsolved