Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. PyQT4: QPushbutton icons and button name
Forum Updated to NodeBB v4.3 + New Features

PyQT4: QPushbutton icons and button name

Scheduled Pinned Locked Moved Unsolved General and Desktop
7 Posts 2 Posters 2.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.
  • S Offline
    S Offline
    SIddharthSavant
    wrote on last edited by SIddharthSavant
    #1

    in push-button i have added a fixed size icon/image ,but when the push-button name length is longer it tends to push out the icon/image out of the push-button also the text moves out of the push-button . How fix the location of the image as well as the text because i cant change the size of the push-button,the size is fixed for push-button!

    jsulmJ 1 Reply Last reply
    0
    • S SIddharthSavant

      in push-button i have added a fixed size icon/image ,but when the push-button name length is longer it tends to push out the icon/image out of the push-button also the text moves out of the push-button . How fix the location of the image as well as the text because i cant change the size of the push-button,the size is fixed for push-button!

      jsulmJ Offline
      jsulmJ Offline
      jsulm
      Lifetime Qt Champion
      wrote on last edited by
      #2

      @SIddharthSavant Why is the size of the button fixed? If it has to be fixed and the text is too long then the only thing you can do is to shorten the text. You should use layouts, so the button can expand if there is enough space. See http://doc.qt.io/qt-5/layout.html and http://doc.qt.io/qt-5/examples-layouts.html

      https://forum.qt.io/topic/113070/qt-code-of-conduct

      S 1 Reply Last reply
      1
      • jsulmJ jsulm

        @SIddharthSavant Why is the size of the button fixed? If it has to be fixed and the text is too long then the only thing you can do is to shorten the text. You should use layouts, so the button can expand if there is enough space. See http://doc.qt.io/qt-5/layout.html and http://doc.qt.io/qt-5/examples-layouts.html

        S Offline
        S Offline
        SIddharthSavant
        wrote on last edited by
        #3

        @jsulm hi, thanks for the advice .The button size fixed because ,within the mainwindow i have five more push-buttons and also screen size is 7 inch and i don't have much room to adjust the size of button. i was hoping to make image location fixed and when text reaches the maximum size of the button it should go to next line rather moving out of screen.Is there any way to do it ?

        jsulmJ 1 Reply Last reply
        0
        • S SIddharthSavant

          @jsulm hi, thanks for the advice .The button size fixed because ,within the mainwindow i have five more push-buttons and also screen size is 7 inch and i don't have much room to adjust the size of button. i was hoping to make image location fixed and when text reaches the maximum size of the button it should go to next line rather moving out of screen.Is there any way to do it ?

          jsulmJ Offline
          jsulmJ Offline
          jsulm
          Lifetime Qt Champion
          wrote on last edited by
          #4

          @SIddharthSavant The question is more: why do you have so long text in your button? Is it really necessary? Multiline text in a button is quite unusual and should be avoided.
          It is possible to have multiple lines of text in a button, but then its hight will increase.

          https://forum.qt.io/topic/113070/qt-code-of-conduct

          S 1 Reply Last reply
          1
          • jsulmJ jsulm

            @SIddharthSavant The question is more: why do you have so long text in your button? Is it really necessary? Multiline text in a button is quite unusual and should be avoided.
            It is possible to have multiple lines of text in a button, but then its hight will increase.

            S Offline
            S Offline
            SIddharthSavant
            wrote on last edited by
            #5

            @jsulm said in PyQT4: QPushbutton icons and button name:

            why do you have so long text in your button?

            yes the long text is necessary ,because i dont have flexibility to reduce the length of text.

            jsulmJ 1 Reply Last reply
            0
            • S SIddharthSavant

              @jsulm said in PyQT4: QPushbutton icons and button name:

              why do you have so long text in your button?

              yes the long text is necessary ,because i dont have flexibility to reduce the length of text.

              jsulmJ Offline
              jsulmJ Offline
              jsulm
              Lifetime Qt Champion
              wrote on last edited by
              #6

              @SIddharthSavant you can insert a "new line" in your text, like:

              QString text = "firstline\nsecondline";
              

              https://forum.qt.io/topic/113070/qt-code-of-conduct

              S 1 Reply Last reply
              1
              • jsulmJ jsulm

                @SIddharthSavant you can insert a "new line" in your text, like:

                QString text = "firstline\nsecondline";
                
                S Offline
                S Offline
                SIddharthSavant
                wrote on last edited by
                #7

                @jsulm thanks for the help.

                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 Extensions
                • Unsolved