PDA

View Full Version : Qt Project to implement Qt Creator's SideBar (FrancyTabBar)



xboxnissan
19th December 2011, 21:44
I would like to implement the Qt's SideBar into my project:

Did My Homework:

I tried searching the web, found the following websites (only 2 results after many search):

1- How do I add a QTCreator-like left bar to my program? (http://stackoverflow.com/questions/6255855/how-do-i-add-a-qtcreator-like-left-bar-to-my-program)

I found fancytabwidget from DimanNe's answer, but I couldn't get the class to work.

2- http://groups.google.com/group/qt-project-list-interest/browse_thread/thread/666273d2d07c627f/1d3e6796b3bfe654?show_docid=1d3e6796b3bfe654&pli=1

Still unanswered.

Could someone help me out ?

Thanks !

MyQt : QtSDK (Latest) with QtSources 4.7.4 and QtCreator Sources.

nish
19th December 2011, 22:50
why dont to take a look into QtCreator source code?

xboxnissan
20th December 2011, 03:22
why dont to take a look into QtCreator source code?

I allready tried, and need help using it : "Simplest way - is to use QtCreator's library libCorePlugin.so and corresponding includes (FancyTabBar.h) from QtCreator's srcs" => That is DimanNe's answer.

I said the following : "but I couldn't get the class to work.".

I'd need someone to assist me to make it work

Lykurg
20th December 2011, 07:26
you don't need the library. Just copy the source and header file to your app. (plus additional files as they are included.)

xboxnissan
20th December 2011, 07:36
you don't need the library. Just copy the source and header file to your app. (plus additional files as they are included.)

I can't Lykurg, because I found that ModeManager and FancyTabWidget is with the MainWindow (QtCreator's main) in a namespace. I tried to modify the source, so that I could send a reference of my QMainWindow, but it failed, saying that 'undifened reference to struct ModeManager' or same result for FancyTabWidget.

Could you help me out?

Lykurg
20th December 2011, 10:14
in fancytabwidget.h: only Qt dependencies.
in fancytabwidget.cpp: only utils/stylehelper.h (no dependencies except Qt) and utils/styledbar.h. And here also no further dependencies. So what is the problem?

Simple include these sex files in your project and use them. They take normal QWidget's as parameters.

What you have to do - if you like - is to remove the namespace.

xboxnissan
20th December 2011, 19:43
in fancytabwidget.h: only Qt dependencies.
in fancytabwidget.cpp: only utils/stylehelper.h (no dependencies except Qt) and utils/styledbar.h. And here also no further dependencies. So what is the problem?

Simple include these sex files in your project and use them. They take normal QWidget's as parameters.

What you have to do - if you like - is to remove the namespace.

I did what you said, got the following errors:

debug/fancytabwidget.o:C:\Users\[MyComp]\Desktop\MainProject\Test\Test/fancytabwidget.cpp:103: undefined reference to `_imp___ZN5Utils11StyleHelper15sidebarFontSizeEv'
debug/fancytabwidget.o:C:\Users\[MyComp]\Desktop\MainProject\Test\Test/fancytabwidget.cpp:280: undefined reference to `_imp___ZN5Utils11StyleHelper15sidebarFontSizeEv'
debug/fancytabwidget.o:C:\Users\[MyComp]\Desktop\MainProject\Test\Test/fancytabwidget.cpp:287: undefined reference to `_imp___ZN5Utils11StyleHelper14panelTextColorEb'
debug/fancytabwidget.o:C:\Users\[MyComp]\Desktop\MainProject\Test\Test/fancytabwidget.cpp:289: undefined reference to `_imp___ZN5Utils11StyleHelper14panelTextColorEb'
debug/fancytabwidget.o:C:\Users\[MyComp]\Desktop\MainProject\Test\Test/fancytabwidget.cpp:312: undefined reference to `_imp___ZN5Utils11StyleHelper18drawIconWithShadowE RK5QIconRK5QRectP8QPainterNS1_4ModeEiRK6QColorRK6Q Point'
debug/fancytabwidget.o: In function `FancyTabWidget':
C:\Users\[MyComp]\Desktop\MainProject\Test\Test/fancytabwidget.cpp:389: undefined reference to `_imp___ZN5Utils9StyledBarC1EP7QWidget'
C:\Users\[MyComp]\Desktop\MainProject\Test\Test/fancytabwidget.cpp:389: undefined reference to `_imp___ZN5Utils9StyledBarC1EP7QWidget'
debug/fancytabwidget.o:C:\Users\[MyComp]\Desktop\MainProject\Test\Test/fancytabwidget.cpp:465: undefined reference to `_imp___ZN5Utils11StyleHelper16verticalGradientEP8 QPainterRK5QRectS5_b'
debug/fancytabwidget.o:C:\Users\[MyComp]\Desktop\MainProject\Test\Test/fancytabwidget.cpp:466: undefined reference to `_imp___ZN5Utils11StyleHelper11borderColorEb'
debug/fancytabwidget.o:C:\Users\[MyComp]\Desktop\MainProject\Test\Test/utils/stylehelper.h:64: undefined reference to `_imp___ZN5Utils11StyleHelper20m_requestedBaseColo rE'
debug/fancytabwidget.o:C:\Users\[MyComp]\Desktop\MainProject\Test\Test/fancytabwidget.cpp:368: undefined reference to `_imp___ZN5Utils11StyleHelper12setBaseColorERK6QCo lor'
collect2: ld returned 1 exit status
mingw32-make.exe[1]: *** [debug\Test.exe] Error 1
mingw32-make.exe: *** [debug] Error 2


Added after 23 minutes:


in fancytabwidget.h: only Qt dependencies.
in fancytabwidget.cpp: only utils/stylehelper.h (no dependencies except Qt) and utils/styledbar.h. And here also no further dependencies. So what is the problem?

Simple include these sex files in your project and use them. They take normal QWidget's as parameters.

What you have to do - if you like - is to remove the namespace.

Check out this https://rapidshare.com/files/2075171030/Test.zip

Lykurg
21st December 2011, 15:01
If you have trouble with that, then - no offense - you should be more concerned with your coding abilities than the gui of your application! Off course you have to extend SOURCES and HEADERS with the includes from fancytabwidget.cpp and so on since you don't use it as a library.

xboxnissan
21st December 2011, 18:41
If you have trouble with that, then - no offense - you should be more concerned with your coding abilities than the gui of your application! Off course you have to extend SOURCES and HEADERS with the includes from fancytabwidget.cpp and so on since you don't use it as a library.

Yes I decided to step foward in looking into C++ sources, and sucessfuly made it work. Still, I had to modify the background, because the two rgb returned black colors, resulting a black background for the fancytabwidget. I had to look into the StyleHelper Class to make my own Gradient, and sucessfuly made it work. Thanks Lykurg :)

norobro
21st December 2011, 19:08
The user can change the background color at any time. See: FancyColorButton::mousePressEvent()

rasufa
28th December 2011, 07:55
I've implemented the sidebar using empty widget and several pushbuttons styled with stylesheets:


layout widget vertically
all buttons are checkable
last button is disabled and its vertical size policy is set to 'expanding' and it contains no text (its role is to decorate sidebar)
implemented rules for QPushButton normal state and 'hover', 'checked', 'disabled' pseudo-classes


And there is no icons in sidebar...

Also I created function to make sure that only one of the buttons is checked:



void MainWindow::switchButtons(QPushButton *b) { // called when button is clicked
if (b != selectedButton) {
selectedButton->setChecked(false);
selectedButton = b;
}
else
selectedButton->setChecked(true);
}


7207