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. How to retrieve the currentPageName property of QStackedWidget
Qt 6.11 is out! See what's new in the release blog

How to retrieve the currentPageName property of QStackedWidget

Scheduled Pinned Locked Moved Solved General and Desktop
2 Posts 2 Posters 512 Views 3 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.
  • M Offline
    M Offline
    Mark81
    wrote on last edited by
    #1

    When editing a QStackedWidget from QtCreator you can set a currentPageName property:

    7589995f-327f-42ce-95f9-13252ab2f903-immagine.png

    But I cannot find how to retrieve this value from code.
    Even the doc page of QStackedWidget does not mention it.

    I tried in this way guessing it was a custom property:

    ui->stackedWidget->setCurrentIndex(0);
    qDebug() << ui->stackedWidget->property("currentPageName");
    

    but it returns an invalid value.

    1 Reply Last reply
    0
    • Chris KawaC Offline
      Chris KawaC Offline
      Chris Kawa
      Lifetime Qt Champion
      wrote on last edited by
      #2

      It's not a property. If you look at the generated code it's just a shortcut for setting the variable and object name i.e. something like this:

      page = new QWidget();
      page->setObjectName("page");
      stackedWidget->addWidget(page);
      

      so to get it back you would do:

      ui->stackedWidget->currentWidget()->objectName()
      
      1 Reply Last reply
      4
      • M Mark81 has marked this topic as solved on

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved