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. QComboBox drop-down stylesheet issue

QComboBox drop-down stylesheet issue

Scheduled Pinned Locked Moved Solved General and Desktop
5 Posts 2 Posters 2.6k 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.
  • A Offline
    A Offline
    Andrea
    wrote on last edited by
    #1

    Hi folks,

    after have spent hours in googling and trying, I'm still unable to resize drop-down width button of QComboBox with StyleSheet.
    The thing looks to be easy, but, actually, not to me.
    My code line is this (where myObject is parent of everything in the application):

    myObject->setStyleSheet("QComboBox::drop-down { width: 34px;}");

    but drop-down doesn't change its size, keeping the default one!

    QComboBox in my project has nothing special, just a QListView setted as its view to increment items' spacing (it's a touch screen application, that's why I need a bigger drop-down button). Here how it's defined:

    ListView->setStyleSheet("QListView::item { margin: 7px;}\n");
    ListView->setFocusPolicy(Qt::NoFocus);
    this->setView(ListView); // "this" is a QComboBox derived class

    Hope anyone can help me to fix this problem,

    Thanks in advance
    Andrea

    J 1 Reply Last reply
    0
    • A Andrea

      Hi folks,

      after have spent hours in googling and trying, I'm still unable to resize drop-down width button of QComboBox with StyleSheet.
      The thing looks to be easy, but, actually, not to me.
      My code line is this (where myObject is parent of everything in the application):

      myObject->setStyleSheet("QComboBox::drop-down { width: 34px;}");

      but drop-down doesn't change its size, keeping the default one!

      QComboBox in my project has nothing special, just a QListView setted as its view to increment items' spacing (it's a touch screen application, that's why I need a bigger drop-down button). Here how it's defined:

      ListView->setStyleSheet("QListView::item { margin: 7px;}\n");
      ListView->setFocusPolicy(Qt::NoFocus);
      this->setView(ListView); // "this" is a QComboBox derived class

      Hope anyone can help me to fix this problem,

      Thanks in advance
      Andrea

      J Offline
      J Offline
      Jakob
      wrote on last edited by
      #2

      @Andrea Have you tried

      qApp->setStyleSheet(....)
      

      Btw: I'm not sure what you're trying to accomplish by creating a different object than qApp as the parent of 'everything', but this sounds like a very bad idea, since such an object already exists, namely qApp

      1 Reply Last reply
      1
      • A Offline
        A Offline
        Andrea
        wrote on last edited by
        #3

        @Jakob Thanks for your suggestion, now it works.

        About the "parent of everything", I've forgotten of QApplication, which still does its function. My object is simply something that contains every frame, objects and other to be displayed.

        Many thanks
        Andrea

        J 2 Replies Last reply
        0
        • A Andrea

          @Jakob Thanks for your suggestion, now it works.

          About the "parent of everything", I've forgotten of QApplication, which still does its function. My object is simply something that contains every frame, objects and other to be displayed.

          Many thanks
          Andrea

          J Offline
          J Offline
          Jakob
          wrote on last edited by
          #4

          @Andrea You mentioned 'My object is simply .... to be displayed' - if that were really the case, setting the stylesheet on that object should work AFAIK.

          If I understand you correctly, you're talking about some QMainWindow-ish type of object. That would actually make sense, and is not a bad idea, but the standard Qt-way, so neglect my previous remark about that. But still it surprises me that didn't work, as stylesheet are supposed to be 'cascading'. But alas, if it works, it works!

          1 Reply Last reply
          0
          • A Andrea

            @Jakob Thanks for your suggestion, now it works.

            About the "parent of everything", I've forgotten of QApplication, which still does its function. My object is simply something that contains every frame, objects and other to be displayed.

            Many thanks
            Andrea

            J Offline
            J Offline
            Jakob
            wrote on last edited by
            #5

            @Andrea Oh, btw, if the issue has been resolved, don't forget to mark the question as solved, using the box at the bottom right of the original question.

            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