Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. [Solved]select effect in pushbuttons
Forum Update on Monday, May 27th 2025

[Solved]select effect in pushbuttons

Scheduled Pinned Locked Moved Mobile and Embedded
5 Posts 2 Posters 3.4k 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
    alfah
    wrote on 20 Jul 2011, 06:57 last edited by
    #1

    :)
    i come again with yet another button problem. Ive created an array of buttons with out using the designer.

    @cellBut[i][j]=new QPushButton();
    connect(cellBut[i][j],SIGNAL(clicked()),this,SLOT(onClickAction()));@

    these are arranged in rows , a calender sorta thing, and i want to select them when clicked once, jus to know tht ive clicked that particular date. It gives the default "pressed and released effect" but not the highlighted effect.

    I want it do the highlighting jus like how the default calenderwidget does.

    is there some highlight function thing. I found an autofill backgroundthing or setMask, but it does nothing, or i dont know how to use it.
    or if i get a pointer of the selected date, does it have the function to select???

    Guide me on this please

    Thank you

    1 Reply Last reply
    0
    • F Offline
      F Offline
      Franzk
      wrote on 20 Jul 2011, 09:40 last edited by
      #2

      Did you setCheckable(true)? If you didn't, do it. After that, you can probably change the style sheet to show some differing background color when the button is pressed.

      "Horse sense is the thing a horse has which keeps it from betting on people." -- W.C. Fields

      http://www.catb.org/~esr/faqs/smart-questions.html

      1 Reply Last reply
      0
      • A Offline
        A Offline
        alfah
        wrote on 20 Jul 2011, 11:38 last edited by
        #3

        thanks franzk

        can we uncheck it programatically. Meaning setCheckable(true) wil check it once clicked right. but even if i click the next button, both the currently clicked and previously clicked are checked :)

        jus like minesweepers :) i don want tht. i want to uncheck the previously clicked one.

        thank you

        1 Reply Last reply
        0
        • F Offline
          F Offline
          Franzk
          wrote on 20 Jul 2011, 12:02 last edited by
          #4

          See QAbstractPushButton::setChecked().

          "Horse sense is the thing a horse has which keeps it from betting on people." -- W.C. Fields

          http://www.catb.org/~esr/faqs/smart-questions.html

          1 Reply Last reply
          0
          • A Offline
            A Offline
            alfah
            wrote on 10 Aug 2011, 06:12 last edited by
            #5

            The select effect can be done either putting images for the pressed and not pressed state.
            So set the stylesheet to suit your needs.

            Ex:
            @

            QPushButton#settingBut { color: rgb(0, 0, 0);

             border-width: 1px;
             border-radius: 10px;
             font: bold 20px;
             min-width: 8em;
             padding: 5px;
            

            }

            QPushButton#settingBut:pressed
            {
            border-style:solid;
            border-width:2px;
            }
            @

            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