PDA

View Full Version : Best widget to use as container for row of QPushButtons?



Coolname007
25th November 2012, 19:25
Hello friends,
I was wondering what the best widget in QT is for acting as an container for a row of QPushButtons?
Any recommendations?

The push buttons will act as tabs for a different "page" in the main window (i.e. a page which will contain a different interface and different controls depending on which tab button is currently selected). My central widget of my main window is a QTextEdit. The idea is to have a different document loaded into that text editor for each tab, i.e. the document corresponding to the interface currently shown, so that a user can switch back and forth from one "page" to another at his leisure, and any changes he makes to the current document loaded into the editor will be saved between switching back and forth.

Thanks.

Zlatomir
25th November 2012, 19:47
Tell us more about what you didn't manage to achieve, anyway generic answers:
1) to hold the pointers in code you can use a QList<QPushButton*> and do all the work by yourself...
1.1) to organize the buttons in gui you can use a QGroupBox (http://doc.qt.digia.com/qt/qgroupbox.html#details)
or
2) also take a look at QTabWidget (http://doc.qt.digia.com/stable/qtabwidget.html#details) - i think is a better solution... mainly because it has the native look and feel of such functionality.

wysota
25th November 2012, 19:49
You can use QTabBar or just put the set of buttons in a horizontal layout.

Coolname007
25th November 2012, 20:24
Tell us more about what you didn't manage to achieve, anyway generic answers:
1) to hold the pointers in code you can use a QList<QPushButton*> and do all the work by yourself...
1.1) to organize the buttons in gui you can use a QGroupBox (http://doc.qt.digia.com/qt/qgroupbox.html#details)
or
2) also take a look at QTabWidget (http://doc.qt.digia.com/stable/qtabwidget.html#details) - i think is a better solution... mainly because it has the native look and feel of such functionality.
Hey, thanks. Yes, I like the QTabWidget suggestion. I am busy implementing that right now.

As for QGroupBox, I had already looked at that one, but it appeared to me that that kind of widget kind of likes to present its controls in a vertical structure, and I was wanting my buttons to be in a horizontal structure...thus me searching for something else that would work.