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. How to set the spacing of toolbar's actions?
Forum Updated to NodeBB v4.3 + New Features

How to set the spacing of toolbar's actions?

Scheduled Pinned Locked Moved Solved General and Desktop
5 Posts 3 Posters 2.9k Views 1 Watching
  • 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.
  • L Offline
    L Offline
    Limer
    wrote on 23 Oct 2018, 12:40 last edited by
    #1
    QAction* playAction = new ...
    QAction* pauseAction = new ...
    QAction* replayAction = new ...
    
    QMenuBar* menuBar = new ...
    menuBar->addAction(playAction...);
    menuBar->addAction(pauseAction...);
    menuBar->addAction(replayAction...);
    

    I want to set the spacing of these actions to 10px, so I wrote the code as below:

    menuBar->setStyleSheet("QToolBar::item{spacing: 10px;}");
    

    But it didn't work, so I went on to try to use qss code QToolBar::item{margin: 0px 10px;} and QToolBar::item{padding: 10px;} , all failed.

    e,,,,What should I do if I want to set the spacing of these actions?

    J 1 Reply Last reply 23 Oct 2018, 15:51
    0
    • L Limer
      23 Oct 2018, 12:40
      QAction* playAction = new ...
      QAction* pauseAction = new ...
      QAction* replayAction = new ...
      
      QMenuBar* menuBar = new ...
      menuBar->addAction(playAction...);
      menuBar->addAction(pauseAction...);
      menuBar->addAction(replayAction...);
      

      I want to set the spacing of these actions to 10px, so I wrote the code as below:

      menuBar->setStyleSheet("QToolBar::item{spacing: 10px;}");
      

      But it didn't work, so I went on to try to use qss code QToolBar::item{margin: 0px 10px;} and QToolBar::item{padding: 10px;} , all failed.

      e,,,,What should I do if I want to set the spacing of these actions?

      J Offline
      J Offline
      JonB
      wrote on 23 Oct 2018, 15:51 last edited by
      #2

      @Limer
      I don't know what the correct answer is, but I do know that ::item() is for e.g. QMenuBar but not for QToolBar.... Other people seem to use QToolButton to address the buttons?

      L 1 Reply Last reply 24 Oct 2018, 11:20
      1
      • M Offline
        M Offline
        mrjj
        Lifetime Qt Champion
        wrote on 23 Oct 2018, 18:39 last edited by
        #3

        Hi
        Did you try
        setStyleSheet('QToolBar{spacing:10px;}'

        L 1 Reply Last reply 24 Oct 2018, 11:10
        1
        • M mrjj
          23 Oct 2018, 18:39

          Hi
          Did you try
          setStyleSheet('QToolBar{spacing:10px;}'

          L Offline
          L Offline
          Limer
          wrote on 24 Oct 2018, 11:10 last edited by
          #4

          @mrjj Sorry, it didn't work.

          1 Reply Last reply
          0
          • J JonB
            23 Oct 2018, 15:51

            @Limer
            I don't know what the correct answer is, but I do know that ::item() is for e.g. QMenuBar but not for QToolBar.... Other people seem to use QToolButton to address the buttons?

            L Offline
            L Offline
            Limer
            wrote on 24 Oct 2018, 11:20 last edited by
            #5

            @JonB said in How to set the spacing of toolbar's actions?:

            QToolButton

            use QToolButton{margin: 0px 10px;}, it works.... thanks very much.

            1 Reply Last reply
            2

            5/5

            24 Oct 2018, 11:20

            • Login

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