Changing cursor in QTabBar
-
Hey, I solved this problem. This is my last code
//maingui.h #include <QTabBar> ... private slots: ... void mouseMoveEvent(QMouseEvent *event); private: QList<QTabBar *> tabBar ;
This is the CPP File
//maingui.cpp MainGUI::MainGUI(QWidget *parent) : QDialog(parent, Qt::WindowTitleHint | Qt::WindowMinimizeButtonHint | Qt::WindowCloseButtonHint | Qt::WindowMaximizeButtonHint), ui(new Ui::MainGUI) { ui->setupUi(this); setMouseTracking(true); ... } void MainGUI::mouseMoveEvent(QMouseEvent *event){ tabBar = this->ui->tabWidget->findChildren<QTabBar *>(); tabBar.at(0)->setCursor(Qt::PointingHandCursor); }
But sometimes its not initialize for the first time. Thank you
-
Hai everyone. I want to ask. How to change the cursor when the curson in Tab Bar? I try
ui->tab->setCursor(Qt::PointingHandCursor);
but the cursor change in the whole of tabwidget
@mimamrafi I don't think you can without subclassing; there is no header property that would return the tab headers only.
-
Hai everyone. I want to ask. How to change the cursor when the curson in Tab Bar? I try
ui->tab->setCursor(Qt::PointingHandCursor);
but the cursor change in the whole of tabwidget
@mimamrafi
install an eventfilter on the tabbar and on mousemove events check QTabBar::tabAt() >= 0 to set your cursor, else restore the cursor -
@mimamrafi I don't think you can without subclassing; there is no header property that would return the tab headers only.
-
@mimamrafi
install an eventfilter on the tabbar and on mousemove events check QTabBar::tabAt() >= 0 to set your cursor, else restore the cursor@raven-worx yes, I'm using mouse movement event filter. But I still can't get the tab bar
-
Hey, I solved this problem. This is my last code
//maingui.h #include <QTabBar> ... private slots: ... void mouseMoveEvent(QMouseEvent *event); private: QList<QTabBar *> tabBar ;
This is the CPP File
//maingui.cpp MainGUI::MainGUI(QWidget *parent) : QDialog(parent, Qt::WindowTitleHint | Qt::WindowMinimizeButtonHint | Qt::WindowCloseButtonHint | Qt::WindowMaximizeButtonHint), ui(new Ui::MainGUI) { ui->setupUi(this); setMouseTracking(true); ... } void MainGUI::mouseMoveEvent(QMouseEvent *event){ tabBar = this->ui->tabWidget->findChildren<QTabBar *>(); tabBar.at(0)->setCursor(Qt::PointingHandCursor); }
But sometimes its not initialize for the first time. Thank you