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. Alternating row colors in mac and linux
Forum Updated to NodeBB v4.3 + New Features

Alternating row colors in mac and linux

Scheduled Pinned Locked Moved General and Desktop
3 Posts 3 Posters 3.7k 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.
  • I Offline
    I Offline
    inopportuno
    wrote on last edited by
    #1

    I want to alternate the colors of a QComboBox. In Windows I have no problem using the view().setAlternatingRowColors(true) function. In Linux and Mac it looks like impossible. I tried also using style sheet (see following code) but I had the same kind of results (all rows with the same background color). Can you explain me what is my error?

    @#include <QtGui/QApplication>
    #include <QComboBox>
    #include <QAbstractItemView>

    int main(int argc, char *argv[])
    {
    QApplication a(argc, argv);
    a.setStyleSheet("QComboBox QAbstractItemView{qproperty-alternatingRowColors: true;alternate-background-color: blue;background: red;}");
    QComboBox b;
    b.addItem("MM_NONE");
    b.addItem("MM_VERT");
    b.addItem("MM_FACE");
    b.addItem("MM_EDGE");
    bool tt = false;
    tt = b.view()->alternatingRowColors();
    b.show();
    return a.exec();
    }@

    1 Reply Last reply
    0
    • P Offline
      P Offline
      PSI-lbc
      wrote on last edited by
      #2

      This seems to work on my Mac...

      @
      #include <QtGui/QApplication>
      #include "MainWindow.h"

      int main(int argc, char *argv[])
      {
      #ifdef Q_WS_WIN
      // Winduhs
      QApplication::setStyle("windowsvista");
      #else
      // Mac
      QApplication::setDesktopSettingsAware(false);
      QApplication::setColorSpec(QApplication::ManyColor);
      QApplication::setStyle("plastique");
      #endif

      QApplication a(argc, argv);

      a.setStyleSheet("QComboBox QAbstractItemView{qproperty-alternatingRowColors: true;alternate-background-color: lightGray;background: white;}");

      MainWindow w;
      w.show();

      return a.exec();
      }
      @

      1 Reply Last reply
      0
      • M Offline
        M Offline
        mkoskim
        wrote on last edited by
        #3

        I have had the same problem(?), with GTK and Qt. The reason for this behavior is the theme the computer is using - it may not have alternate colors for rows, even if you request it. This is the case at least with Linux Mint I use, no program has alternating row colors in their list boxes.

        So, basically, you should do nothing, as it is generally good to obey user's settings. If you want them visible, you should change your personal desktop settings.

        http://mkoskim.wordpress.com
        http://mkoskim.drivehq.com
        http://mkoskim.deviantart.com

        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