hello everybody
i have a problem with customization of the QTabWidget
i want it to look like this:
i attached a picture
any idea
Printable View
hello everybody
i have a problem with customization of the QTabWidget
i want it to look like this:
i attached a picture
any idea
maybe use setTabPosition( TabPosition ) of QTabWidget. TabPosition = QTabWidget::West.
I don't test, you can try.
i'v tried the setTabPosition but i want to change the tab text direction to be vertical to the widget.
thanx anyway
could u solved this problem.I need the same thing into bottom side.can u help me plz ? how to set tabposition?
Hey don't hijack 2 year old post! RTMF or at least read the thread you are writing in. The first answer tells you the solution!
This maybe help you:
http://blog.csdn.net/notton/archive/...9/5996730.aspx
http://hi.csdn.net/attachment/201011...2695378IfX.gif
--------------------------------------------------
--------- Welcome www.thinkvd.com -------
--------------------------------------------------
Wait... seriously, "Guru", "Nokia Certified / Qt Developer"? At least you could follow your own comment "AT LEAST READ THE THREAD YOU ARE WRITING IN".
Setting the TabWidget to WEST won't do what the poster asked for. And he already wrote it in the 3rd msg of this thread.
I'm reading threads and it's full of little bastard saying "Read the f... manual".
Maybe you should tell your mom "Hey bi@tch, you probably did't RTFM about how to raise kids!"
By the way, it's RTFM, not RTMF... at least when you insult people, do it correctly!
Which came long after that post...
Beside that, you must be really upset if your first post is to tell that (without helping the thread starter in any way). And as you obviously are stressed I was that time, and we both used a post to relieve that pressure. Not the right way, but as you showed with your post, we are not such different ;-)
And I don't know what my mother have to do with it...
+1 to cdebel2005
I've had this problem (and still do btw) and came across this thread.
Reading answers like "RTFM (ahh... sorry RTMF)" is a waste of everybody's time.
If you do not know the answer -- don't post. You are useless and of no help.
And yes, I've used my first post to tell that... Because I am really upset with the "Guru's" like you.
Go ahead blaming me because of a typo. You also seem to not have understand the relation between tags like "Guru" and time of posting. Beside, I didn't gave me the title "Guru". It is just related on how many post you do here. Even if they are crap. So please do not blame me for things I am not responsible for. But anyway go on, dish the dirt, I do not care.
Or you can start spending the time solving your problem. As I am not very willing to help you after such comment (problem is the language not necessarily the content), but for the sake of peace I give a starting point. You just have to change it for your needs:
Code:
class CustomTabStyle : public QProxyStyle { public: { s.transpose(); return s; } void drawControl(ControlElement element, const QStyleOption *option, QPainter *painter, const QWidget *widget) const { if (element == CE_TabBarTabLabel) { { QProxyStyle::drawControl(element, &opt, painter, widget); return; } } QProxyStyle::drawControl(element, option, painter, widget); } }; int main(int argc, char *argv[]) { QTabBar tb; tb.setStyle(new CustomTabStyle); tb.addTab("Tab 1"); tb.addTab("Tab 2"); tb.show(); return a.exec(); }
To protect me against an other shit storm about how a Guru can write such a code: It is not the most elegant solution - I know -, but it is easy, quick and working.
EDIT: For a good starting point of reading: http://qt-project.org/doc/qt-4.8/style-reference.html (section Tabs)
There is another useful thread related to this question (west qtabwidget with horizontal text):
http://www.qtforum.org/article/28672...b-positon.html
Hello Lykurg,
After trying your solution as is, I've got the following:
Attachment 9311
Can you explain pls howto make horizontal text tabs and keep west qtab?
Thank you!
You only have to change a row and add one:Code:
#include <QtGui> class CustomTabStyle : public QProxyStyle { public: { s.transpose(); return s; } void drawControl(ControlElement element, const QStyleOption *option, QPainter *painter, const QWidget *widget) const { if (element == CE_TabBarTabLabel) { { QProxyStyle::drawControl(element, &opt, painter, widget); return; } } QProxyStyle::drawControl(element, option, painter, widget); } }; int main(int argc, char *argv[]) { QTabBar tb; tb.setStyle(new CustomTabStyle); tb.addTab("Tab 1"); tb.addTab("Tab 2"); tb.show(); return a.exec(); }
Hi Lykurg,
Is this possible I use your solution to rotate tab bar text from vertical to horizontal. if possible means how?. I attached my output as image. see this,Attachment 9637
Here is a working example of the QTabWidget based on Lykurg CustomTabStyle class.
Works like charm with QT5.0 && QT5.1
tabdialog.pro:
Code:
QT += widgets SOURCES = main.cpp
main.cpp:
Code:
#include <QtGui> #include <QWidget> #include <QDialog> #include <QApplication> #include <QtWidgets> class CustomTabStyle : public QProxyStyle { public: { s.transpose(); return s; } void drawControl(ControlElement element, const QStyleOption *option, QPainter *painter, const QWidget *widget) const { if (element == CE_TabBarTabLabel) { { QProxyStyle::drawControl(element, &opt, painter, widget); return; } } QProxyStyle::drawControl(element, option, painter, widget); } }; int main(int argc, char *argv[], char *envp[]) { tabWidget->tabBar()->setStyle(new CustomTabStyle); mainLayout->addWidget(tabWidget); tabWidget->show(); return app.exec(); }
to compile (! M$):
Code:
qmake -o Makefile tabdialog.pro make
output:
Attachment 9673
Thanks for this. But I'm having some problems related to size of icon; resizing of tab width, height; setting the color of tab
In tried like this, but I think that's not the proper way to change the size
1. I'm setting 64x64 pix icon, but still it's being displayed as a small icon. How do I set it to show original size of icon ?Code:
{ s.transpose(); return s; }
2. How to give custom width & height to the tab ?
3. How to set the color of tab
Kindly help. Thank you.
Hallo
I know, this is an old Thread but i found it now ;-)
On MAC (Sierra QT5.6) i can't see the Text.
Any ideas?
thx Chris