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. QPushButton text disappears when icon is set
Forum Updated to NodeBB v4.3 + New Features

QPushButton text disappears when icon is set

Scheduled Pinned Locked Moved General and Desktop
2 Posts 2 Posters 1.6k 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.
  • J Offline
    J Offline
    jmalicke
    wrote on last edited by
    #1

    I designed a form in Qt Designer with a QDialogButtonBox (wondering I should scrap this widget). The QDialogButtonBox has two buttons, QDialogButtonBox::Ok and QDialogButtonBox::Cancel.

    When I add an icon to one of the buttons, its text disappears. How can I have a QPushButton in a QDialogButtonBox with both an icon and text?

    @// after this call, the text disappears
    ui.buttonBox->button(QDialogButtonBox::Ok)
    ->setIcon( QIcon("src/main/resources/buttons/check_ok.bmp") );@

    1 Reply Last reply
    0
    • A Offline
      A Offline
      ambershark
      wrote on last edited by
      #2

      Does the button have enough space to show the icon and the text? Maybe the text is just cut off because it isn't resizing properly after the icon is added.

      You could try (and I'm not sure if this would work):

      @
      ui.buttonBox->button(QDialogButtonBox::Ok)->adjustSize()
      @

      Do this after your call to setIcon() and see if anything changes.

      My L-GPL'd C++ Logger github.com/ambershark-mike/sharklog

      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