Is it possible to override non-virtual slots in Qt?
up vote
0
down vote
favorite
I would like to run some of my code when the resizeColumnsToContents
slot gets called. However the resizeColumnToContents
slot is not virtual. Is there any other way to achieve this?
If the slot was virtual this is what I would like to do:
class DerivedTableView : public QTableView
{
public:
void resizeColumnsToContents()
{
printf("The user wants to resize the columnsn");
QTableView::resizeColumnsToContents();
}
};
c++ qt oop
add a comment |
up vote
0
down vote
favorite
I would like to run some of my code when the resizeColumnsToContents
slot gets called. However the resizeColumnToContents
slot is not virtual. Is there any other way to achieve this?
If the slot was virtual this is what I would like to do:
class DerivedTableView : public QTableView
{
public:
void resizeColumnsToContents()
{
printf("The user wants to resize the columnsn");
QTableView::resizeColumnsToContents();
}
};
c++ qt oop
7
You cannot override non virtual function. Who callsresizeColumnsToContents
slot? It's connected to a signal, right? To which one? You can implement your own slot (function) and connect the same signal to that very slot instead.
– vahancho
Nov 21 at 8:40
Ah, great idea. I'll try that. Thank you.
– katrasnikj
Nov 21 at 8:50
1
Ok, I found thatQHeaderView::sectionHandleDoubleClicked
signal calls this slot. Fortunately it is accessible and I can use to connect to my slot. Awesome, thank you.
– katrasnikj
Nov 21 at 9:02
Well you can actually override a non-virtual function as long as you don't call it on a motherclass type pointer, but in your case this is not relevant.
– ymoreau
Nov 21 at 11:16
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I would like to run some of my code when the resizeColumnsToContents
slot gets called. However the resizeColumnToContents
slot is not virtual. Is there any other way to achieve this?
If the slot was virtual this is what I would like to do:
class DerivedTableView : public QTableView
{
public:
void resizeColumnsToContents()
{
printf("The user wants to resize the columnsn");
QTableView::resizeColumnsToContents();
}
};
c++ qt oop
I would like to run some of my code when the resizeColumnsToContents
slot gets called. However the resizeColumnToContents
slot is not virtual. Is there any other way to achieve this?
If the slot was virtual this is what I would like to do:
class DerivedTableView : public QTableView
{
public:
void resizeColumnsToContents()
{
printf("The user wants to resize the columnsn");
QTableView::resizeColumnsToContents();
}
};
c++ qt oop
c++ qt oop
asked Nov 21 at 8:37
katrasnikj
8282818
8282818
7
You cannot override non virtual function. Who callsresizeColumnsToContents
slot? It's connected to a signal, right? To which one? You can implement your own slot (function) and connect the same signal to that very slot instead.
– vahancho
Nov 21 at 8:40
Ah, great idea. I'll try that. Thank you.
– katrasnikj
Nov 21 at 8:50
1
Ok, I found thatQHeaderView::sectionHandleDoubleClicked
signal calls this slot. Fortunately it is accessible and I can use to connect to my slot. Awesome, thank you.
– katrasnikj
Nov 21 at 9:02
Well you can actually override a non-virtual function as long as you don't call it on a motherclass type pointer, but in your case this is not relevant.
– ymoreau
Nov 21 at 11:16
add a comment |
7
You cannot override non virtual function. Who callsresizeColumnsToContents
slot? It's connected to a signal, right? To which one? You can implement your own slot (function) and connect the same signal to that very slot instead.
– vahancho
Nov 21 at 8:40
Ah, great idea. I'll try that. Thank you.
– katrasnikj
Nov 21 at 8:50
1
Ok, I found thatQHeaderView::sectionHandleDoubleClicked
signal calls this slot. Fortunately it is accessible and I can use to connect to my slot. Awesome, thank you.
– katrasnikj
Nov 21 at 9:02
Well you can actually override a non-virtual function as long as you don't call it on a motherclass type pointer, but in your case this is not relevant.
– ymoreau
Nov 21 at 11:16
7
7
You cannot override non virtual function. Who calls
resizeColumnsToContents
slot? It's connected to a signal, right? To which one? You can implement your own slot (function) and connect the same signal to that very slot instead.– vahancho
Nov 21 at 8:40
You cannot override non virtual function. Who calls
resizeColumnsToContents
slot? It's connected to a signal, right? To which one? You can implement your own slot (function) and connect the same signal to that very slot instead.– vahancho
Nov 21 at 8:40
Ah, great idea. I'll try that. Thank you.
– katrasnikj
Nov 21 at 8:50
Ah, great idea. I'll try that. Thank you.
– katrasnikj
Nov 21 at 8:50
1
1
Ok, I found that
QHeaderView::sectionHandleDoubleClicked
signal calls this slot. Fortunately it is accessible and I can use to connect to my slot. Awesome, thank you.– katrasnikj
Nov 21 at 9:02
Ok, I found that
QHeaderView::sectionHandleDoubleClicked
signal calls this slot. Fortunately it is accessible and I can use to connect to my slot. Awesome, thank you.– katrasnikj
Nov 21 at 9:02
Well you can actually override a non-virtual function as long as you don't call it on a motherclass type pointer, but in your case this is not relevant.
– ymoreau
Nov 21 at 11:16
Well you can actually override a non-virtual function as long as you don't call it on a motherclass type pointer, but in your case this is not relevant.
– ymoreau
Nov 21 at 11:16
add a comment |
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53408076%2fis-it-possible-to-override-non-virtual-slots-in-qt%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
7
You cannot override non virtual function. Who calls
resizeColumnsToContents
slot? It's connected to a signal, right? To which one? You can implement your own slot (function) and connect the same signal to that very slot instead.– vahancho
Nov 21 at 8:40
Ah, great idea. I'll try that. Thank you.
– katrasnikj
Nov 21 at 8:50
1
Ok, I found that
QHeaderView::sectionHandleDoubleClicked
signal calls this slot. Fortunately it is accessible and I can use to connect to my slot. Awesome, thank you.– katrasnikj
Nov 21 at 9:02
Well you can actually override a non-virtual function as long as you don't call it on a motherclass type pointer, but in your case this is not relevant.
– ymoreau
Nov 21 at 11:16