[SOLVED] QFormLayout not applied correctly
-
Hi,
- I've a little problem with the layout (QFormLayout) inside a QTabWidget:
It doesn't got applied when adding a QTableWidget via the code:
QTabWidget * t; ... if (!t->layout()->count()) t->layout()->addWidget(new QTableWidget);
This is the code I used for creating the QTabWidget:
tw = new QTabWidget; tw->setLayout(new QFormLayout); tabwidget->addTab(tw, tabtext);
This is the screenshot for more details: http://postimg.org/image/tk4op0igp/.
So what's wrong here?
- Another question: as you can see in the screenshot: I used icons from gnome-icon-theme (http://ftp.gnome.org/pub/GNOME/sources/gnome-icon-theme/) for the QToolBar instead of using the system specific icons (I'm using KDE) : So is their any way to set the QToolBar icons to use the system specific ones instead (I mean cross-platform way) ?
I need some help.
Thanks. - I've a little problem with the layout (QFormLayout) inside a QTabWidget:
-
Hi,
-
What do you mean by it doesn't apply ? You are adding a widget to like you would in e.g. a QVBoxLayout so there's nothing wrong here.
-
The problem with icons is that you only have "centralized" icons on Linux, to my knowledge there's no equivalent for Windows or OS X
-
-
- The added QTableWidget doesn't fill the whole QTabWidget as you can see in the screenshot above.
- I don't want anymore to use icon files.
I want that the icons ( such as cut, copy, paste, undo, redo ... ) inside the QToolBar will be loaded differently as desktop-environment specific, for example I want it to change to KDE icons because I'm on KDE, and to Windows icons when I'm on Windows. What should I do in this case, if I want to use the code rather than icon files ?
-
-
Generally, you have some margin/spacing that application follows.
-
That's what I wrote before: OS X and Windows don't have the concept of centralized icon pools.
-
-
- So, what do you suggest concerning this issue, inside the code?
- So what I should do for those 2 operating systems is using icon files, right ?
-
- Change the margin and spacing but first, why a QFormLayout if you don't use the features from that layout ?
- That's what cross-platform application usually do: ship the icons with the application (beware the licensing of the icon you are using)
-
- the problem doesn't got solved, even I tried the following code:
tw = new QTabWidget; QFormLayout * fl = new QFormLayout; fl->setContentsMargins(0, 0, 0, 0); fl->setSpacing(0); tw->setLayout(fl);
- Ok, I will keep using the GNOME icons.
-
Why are you setting the layout on the QTabWidget ? QTabWidget is a container widget, you should put widgets in it, not use layout on it.
-
@SGaist How this can be done? can you give me an example?
-
QTabWidget *myTabWidget = new QTabWidget; QTableWidget *myTableWidget = new QTableWidget; myTabWidget->addTab(myTableWidget, tr("TableWidget"));
-
@SGaist Thanks anyway, but that didn't solve my problem: because what I want here is adding a tablewidget inside tabwidget container, with the possibility of adding other widgets inside the tabwidget. Finally, I found the solution by myself through using QGridLayout instead of QFormLayout(which was the misleading way): now it works perfectly.
-
I'd recommend to reanalyze your widget creation handling. It looks like you are slowly creating a labyrinth of QWidgets in other QWidgets in QTabWidget contained in other QTabWidget maybe contained in QTabWidget. The complexity of the widgets themselves are not really the problem, but the building of the elements seems to take a complex road that should be cleaned a bit.