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. setCurreentIndex is not bringing focus to tab

setCurreentIndex is not bringing focus to tab

Scheduled Pinned Locked Moved Solved General and Desktop
4 Posts 2 Posters 860 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.
  • Q Offline
    Q Offline
    Qt Enthusiast
    wrote on last edited by Qt Enthusiast
    #1

    class myMainWindow:public QMainWIndow{

    }
    void myMainWindow::setCurrentTab(const QString tabName)
    753 {
    754 if (!tabWidget()) {
    755 return;
    756 }
    757
    758 int count = tabWidget()->count();
    759 int tabIndex = 0;
    760 for (int index =0 ; index < count;index++) {
    761 QString currentTabName = tabWidget()->tabText(index);
    762 if (currentTabName.contains(tabName)) {
    763 break;
    764 }
    765 tabIndex++;
    766 }
    767 tabWidget()->setCurrentIndex(tabIndex);
    768 }

    In this case my tab with tabName is not coming into focus . I have to click tab to bring the tab in focus

    Can some one suggest how to bring tab with tabName into focus

    jsulmJ 1 Reply Last reply
    0
    • Q Qt Enthusiast

      class myMainWindow:public QMainWIndow{

      }
      void myMainWindow::setCurrentTab(const QString tabName)
      753 {
      754 if (!tabWidget()) {
      755 return;
      756 }
      757
      758 int count = tabWidget()->count();
      759 int tabIndex = 0;
      760 for (int index =0 ; index < count;index++) {
      761 QString currentTabName = tabWidget()->tabText(index);
      762 if (currentTabName.contains(tabName)) {
      763 break;
      764 }
      765 tabIndex++;
      766 }
      767 tabWidget()->setCurrentIndex(tabIndex);
      768 }

      In this case my tab with tabName is not coming into focus . I have to click tab to bring the tab in focus

      Can some one suggest how to bring tab with tabName into focus

      jsulmJ Offline
      jsulmJ Offline
      jsulm
      Lifetime Qt Champion
      wrote on last edited by jsulm
      #2

      @Qt-Enthusiast said in setCurreentIndex is not bringing focus to tab:

      tabIndex

      Did you check the value of tabIndex?
      And what do you mean by focus?

      https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • Q Offline
        Q Offline
        Qt Enthusiast
        wrote on last edited by
        #3

        Yes I checked

        Can some one suggest how to bring tab with tabName into focus means
        when I press the Up arrrow key the it gets appiled to other tab not the tabName I set

        jsulmJ 1 Reply Last reply
        0
        • Q Qt Enthusiast

          Yes I checked

          Can some one suggest how to bring tab with tabName into focus means
          when I press the Up arrrow key the it gets appiled to other tab not the tabName I set

          jsulmJ Offline
          jsulmJ Offline
          jsulm
          Lifetime Qt Champion
          wrote on last edited by
          #4

          @Qt-Enthusiast What about calling http://doc.qt.io/qt-5/qwidget.html#setFocus on the tab you select?

          https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply
          2

          • Login

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