【问题标题】:disable progress bar animation in Qt在 Qt 中禁用进度条动画
【发布时间】:2013-05-15 03:45:11
【问题描述】:

是否可以在 Qt 中禁用进度条的动画并使其表现得像一个仪表?

以下是默认行为,我希望它不要让闪亮的波浪定期通过它。我希望用它来显示已使用的资源,例如 CPU、内存和磁盘空间。

【问题讨论】:

    标签: windows qt progress-bar pyqt4


    【解决方案1】:

    用于 qt 设计器的 css:

     QProgressBar::chunk {
         background-color: #3add36;
         width: 1px;
     }
    
     QProgressBar {
         border: 2px solid grey;
         border-radius: 0px;
         text-align: center;
     }
    

    pyqt 示例:

    my_progress_bar = QProgressBar()
    my_progress_bar.setStyleSheet(" QProgressBar { border: 2px solid grey; border-radius: 0px; text-align: center; } QProgressBar::chunk {background-color: #3add36; width: 1px;}")
    

    【讨论】:

    • 嗯,这很难看。有没有更原生的方法?
    • 我发现""" QProgressBar::chunk { background-color: rgb(0, 179, 0); width: 1px; } QProgressBar { border: 1px solid #acacac; border-radius: 0px; text-align: center; background: #dfdfdf; } """ 虽然不完美,但看起来更像本地人
    【解决方案2】:

    看起来您正在使用的进度条是Windows Vista look。您应该能够通过更改 stylesheet 来修改行为。尝试替换背景、进度条的图像和/或块。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-07-16
      • 1970-01-01
      • 2014-04-23
      • 1970-01-01
      • 1970-01-01
      • 2015-06-19
      • 1970-01-01
      相关资源
      最近更新 更多