[solved]QTabWidget problem: Clicking on disabled tab.



  • 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.


  • Moderators

    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.



  • 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 ?


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.