How to link two xibs? - cell

I've to custom cells each in an seperatea .xib file (and for each of them a seperate .h and .m file)
I need these two custom cells in my tableview (Controller). Thats an seperate file, too.
How is it posible to link the two custom cells to the tableviewController?

In your cellForRowAtIndexPath method in the data source of the tableview (in many cases the tableview controller instance), load the approprate nib file.

Related

Qt - Create a simple theming system (changing colors of GUI)

I want to be able to create an simple internal theming system for my program (by internal I mean I don't need to be able to load custom themes from user system... all themes will be embedded inside the program itself.)
I can think of some ways:
simply put all color inside the main stylesheet of the program, every time the colors need to change, retrieve main stylesheet, parse and change the colors, and then reapply it again (or have multiple stylesheet with different colors, and apply them when its needed).
Create a top widget that only hold the colors for each widget, and then a child widget that hold other stylesheet for other styling, and all the UI as child of this widget... in this way we need to only change the first stylesheet.
... (not sure about other ways, but I'm sure there is some... maybe using QStyle or something..?)
I'm not sure what is the best way to achieve what I'm after, that will be best at both performance and the code itself...
I know the first way will be heavy in performance side, to each time change the whole stylesheet and rerender the whole program. (I think at least)
the second option though, I'm not sure how it will work, I mean its any better then the first one?!
or there is any other better methods..?
you should create a .qss file and add it in your .qrc like you add your icons.
then write all your stylesheet there. you can have multiple Style.qss files and these files are your themes and whenever you change it your theme will change.
add your Style.qss File in your Resources(.qrc)
write these codes in main.cpp
Load the application style
QFile styleFile(":/style.qss");
styleFile.open(QFile::ReadOnly);
Apply the loaded stylesheet
QString style(styleFile.readAll());
a.setStyleSheet(style);
For more information :
https://github.com/GTRONICK/QSS
https://github.com/ColinDuquesnoy/QDarkStyleSheet

Change data representation structure in QSortFilterProxyModel

I have custom QSortFilterProxyModel class that i'm using with QFileSystemModel and displaying it in QTreeView. I need to do the following: if there exists folder and file that has identical names (ignoring file extension) files from folder must be docked to this file. For example i have Creatures.txt file and Creatures folder that contains two txt files. I want hide it from final view and display as shown in second picture.
To my understanding QSortFilterProxyModel is used only for filtering and sorting, not for changing data structure. I also need to create/drag-and-drop files in viewport.
This is rather tricky to do, because there is no flag to toggle the visibility of an item in the model.
Instead you could create your own proxy model that omits these items. (That means to reimplement rowCount(), data(), flags() etc. appropriately.)
But if it is Ok to change the visibility on the view side, as a workaround it might be easier for you to use QTreeView::setRowHidden() instead.
Edit: Perhaps overriding QSortFilterProxyModel::filterAcceptsRow() is even easier.

How to make a QheaderView multilevel?

I am creating an application that saves the data of an object sending service.
I created that with Qt, a model of type QStandardItemModel that I want to display with QtableView.
But QtableView shows me the line level on the left. I want to delete it or hide it if possible.
I also have a problem with a header that I want to divide into two horizontally then divide the corresponding part of the bottom in two vertically. The reason for these division is that I have two headers with similar beginnings (date of correspondence and correspondence number)
Thank you for your reply because it is really important for me.
This type of QHeaderView does not exist, but we can create it for it we must create a class that inherits from QHeaderView and rewrite mainly the method paintSection which is the method in charge of drawing the sections of the QHeaderView.
But to do the generic project for any type of visual design we have to keep the information of the position and size of each section, for this we will create a model, to understand why of the overwritten classes I recommend you read content of the following link.
Explain the logic of each method is extensive so only place the link of the project that implements the above and describe the task of each class:
TableHeaderItem: It is responsible for saving the information of each item, mainly rowspan and columnspan in addition to the label.
GridTableHeaderModel: Model class that provides access to each item so that we can edit and read each item
GridTableHeaderView: This class is the custom QHeaderView where the main methods are overwritten to get the desired look.
GridTableView(optional): is a TableView that has methods to work directly with GridTableHeaderView.
Output:
Note: to hide the vertical header it is only necessary to use the hide() method:
horizontalHeader()->hide();

XCode assistant editor doesn't show my .h and my related .cpp file

If I create .cpp file from xcode, it will create .h file for me automatically, and I will be able to view two files together in Assistant Editor. It will show .h file relate to .cpp file right next to each other.
However, I create my project from TextMate and import those files manually. Now, when I click .h file it won't show the related cpp file right next to it. How can I make that happen.
Thanks
Hmmm.. I tried to recreate your problem, but it worked for me.
I have two thoughts:
1) Are you sure they are named the same thing? If not, it doesn't seem to consider them counterparts.
2) When you've switched to the Assistant Editor, to the right of the back/forward buttons is a dropdown menu to select which file to display. This should be set to "Counterparts" in order to get it to auto-display the correct counterpart.
If you have this set to manual, you can set it to maintain a certain file on the side.
Hope this helps!
Go into Xcode (v4) Organizer...Choose Projects.
Find your project and delete the Derived Data. Then rebuild the project.
Choose you view and in the Utilities View, in the Identity Inspector tab, In the Class text field, put down your class name.
Save
The relevant class will appear in the assistent editor.

Extract a portion of a Qt .ui file into its own .ui file

We have a designer creating a user interface for an application. The main window has several QStackedWidgets used for in place panel switching. What I'd like to be able to do is extract each individual panel that makes up each page of the QStackedWidget into it its own .ui file.
Is there an easy way to accomplish this from within Qt Designer, or are there any other tools to help accomplish this task short of redesigning all of the panels in their own .ui files?
You can cut/paste each panel into a blank QWidget (created with File > New), and save these widgets in their own .ui file.
When you copy a widget(lets call it widgetA) that contains other widgets(calling them miniWidgets) then the miniWidgets should still be layed out. WidgetA still needs a relayout and in that case its very easy to add a layout since you can practically use any layout you want (i suggest vertical or horizontal). Just right click on the widget containing widgetA then select Layout->horizontal Layout and that should do the trick.
If there is more than one widget than needs relayout then you are not copying the panel correctly and should copy one that englobes more of the panel.