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.
  • LimerL Offline
    LimerL Offline
    Limer
    wrote on 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?

    JonBJ 1 Reply Last reply
    0
    • LimerL Limer
      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?

      JonBJ Online
      JonBJ Online
      JonB
      wrote on 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?

      LimerL 1 Reply Last reply
      1
      • mrjjM Offline
        mrjjM Offline
        mrjj
        Lifetime Qt Champion
        wrote on last edited by
        #3

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

        LimerL 1 Reply Last reply
        1
        • mrjjM mrjj

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

          LimerL Offline
          LimerL Offline
          Limer
          wrote on last edited by
          #4

          @mrjj Sorry, it didn't work.

          1 Reply Last reply
          0
          • JonBJ JonB

            @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?

            LimerL Offline
            LimerL Offline
            Limer
            wrote on 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

            • Login

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