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. [solved]QTabWidget problem: Clicking on disabled tab.
Forum Updated to NodeBB v4.3 + New Features

[solved]QTabWidget problem: Clicking on disabled tab.

Scheduled Pinned Locked Moved General and Desktop
3 Posts 2 Posters 1.3k 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.
  • S Offline
    S Offline
    shashanksm
    wrote on 10 Jan 2015, 16:31 last edited by
    #1

    Greetings to all. I'm still a novice programmer and started using qt5 from yesterday. The problem I encountered was this ;

    I created a QTabWidget with three pages, holding three widgets. In the constructor of my widget, i disabled last two tabs with tabWidget->setTabEnabled(1,false); tabWidget->setTabEnabled(2,false).

    Everything works fine, my application runs and does all the work in normal flow, but when clicked on disabled tab, the program ends abruptly. Do I need to add some try-catch block to catch exception or what ? what exactly is causing problem ?

    Thanks in advance.

    1 Reply Last reply
    0
    • J Offline
      J Offline
      JKSH
      Moderators
      wrote on 10 Jan 2015, 16:42 last edited by
      #2

      Hi, and welcome to the Qt Dev Net!

      [quote author="shashanksm" date="1420907512"]Everything works fine, my application runs and does all the work in normal flow, but when clicked on disabled tab, the program ends abruptly. Do I need to add some try-catch block to catch exception or what ? what exactly is causing problem ?[/quote]No, you don't need to catch exceptions (Qt does not throw any).

      What you do need is to run your program inside a debugger -- it will help you find out what's causing the crash.

      Qt Doc Search for browsers: forum.qt.io/topic/35616/web-browser-extension-for-improved-doc-searches

      1 Reply Last reply
      0
      • S Offline
        S Offline
        shashanksm
        wrote on 10 Jan 2015, 17:27 last edited by
        #3

        That was a quick reply ! I really appreciate it. Thanks JKSH. Ok, so i ran the debugger, I got what was the problem...

        I had my app connected to a slot on recieving tabBarClicked(int) event. The function in the slot ran even when tab was disabled. So I added an if() condition in the slot and now the app does not crash. But is that supposed to happen ? Can disabled tabs trigger events ?

        1 Reply Last reply
        0

        1/3

        10 Jan 2015, 16:31

        • Login

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