How to add another Gtk::Box in Gtkmm C++ - c++

I want to add another Box to my window in the Gtk example, so that I can put other elements below menu.
Here is the link to example:
12.4.1. Main Menu example
I have searched for it, but found HBox/Vbox, but in the example, there is Box declared, with Gtk::ORIENTATION_VERTICAL
How do I add a simple element like lable or button below the menu?

You already have a Box whose Orientation is set to Vertical and you can easily add other elements like buttons and labels to it.
So add a button below the menubar as following:
Gtk::Widget* pMenubar = m_refUIManager->get_widget("/MenuBar");
if(pMenubar)
m_Box.pack_start(*pMenubar, Gtk::PACK_SHRINK);
Gtk::Button* pButton = new Gtk::Button(Gtk::Stock::OK);
m_Box.pack_start(*pButton, Gtk::PACK_SHRINK);
show_all_children();
P.S: For a better visualization I'd recommend using Glade to see how it should look, what should go where, how packing is done. And then you can easily do the same in your C++ code.

Related

C++ wxWidgets: Change Font of Sizer

I recently started learning C++ and wxWidgets and now I'm building a calculator program. I have a grid sizer with buttons and I want to know is it possible to change the font of the whole sizer instead of changing the font of every single button?
Sizers are not windows and so don't have any font, so, no, you can't just call SetFont() on a sizer. You can iterate over all sizer items and call SetFont() on each item which is a window. Or, somewhat less efficiently (because you "waste" a window), but more conveniently, you can make all your button children of a wxPanel and associate the existing sizer with this panel. Then you'd be able to call SetFont() on the panel, which is a window, and so would propagate the font change to all of its children by default.
Another solution might be to create a child of wxButton that will take the number in constructor and change the font there.

QT Drag and Drop Event Between List Widget and GraphicView

I have a ListWidget whose elements are all icons, and I have a GraphicsView on the other side. Here is the ListWidget event code:
void MainWindow::on_zemin_buton_clicked()
{
ui->aksesuar_ornekleri->clear();
ui->aksesuar_ornekleri->setViewMode(QListWidget::IconMode);
ui->aksesuar_ornekleri->setIconSize(QSize(50,50));
ui->aksesuar_ornekleri->setResizeMode(QListWidget::Adjust);
ui->aksesuar_ornekleri->addItem(new QListWidgetItem(QIcon("../1.jpg"),"11"));
ui->aksesuar_ornekleri->addItem(new QListWidgetItem(QIcon("../2.jpg"),"12"));
ui->aksesuar_ornekleri->addItem(new QListWidgetItem(QIcon("../3.jpg"),"13"));
}
When I click the push button, it clears the list and fills it with the right icons. (I have 4-5 more button click events like this.)
I just want to drag these icons and drop them into the GraphicsView. How can I do that? Should I set up the right design settings or write some drag-drop event code myself?
Edit: Now I realize that I want to do the exact thing with the Qt GUI toolbox. I want to add icons but don't want them to disappear from my list too.

How to add QMenus or Qactions on a Widget like QlistWidget area as a list item?

Is there any way to add QActions as a list item on QListWidget?
I want to make a customization window which will show list of actions on a widget for move up, move down, Rename and other options. I'd like to display it on the widget same as it appears as a context menu.
I tried adding it as a list item with icon and text, but the look it not very good:
i) list items with blank icon are not aligning properly, even after adding a blank icon of size 16*16 is not taking up any space and text with icons & w/o icon are not aligning.
ii) I'm unable to add right-pointing black triangle at the right most, in-case of sub-menus cause somehow unicode character for this is not getting displayed on my Linux machine.
That's why I want to add QActions as it are getting popped at original place.
Any suggestions?
Yes I have a suggestion : do not try to make fancy widgets like this, users will not find it intuitive
You should find another way to implement this.
Imo, something like a QToolButton with a QToolButton::MenuButtonPopup popup mode will do the trick. This way, you can embed menu and sub-menus in a widget, using QToolButton::setMenu().

wxFormBuilder Toolbar Spacing

I am creating a layout using wxFormBuilder. I have a frame, wxBoxSizer (wxToolBar and wxListBook in it) and a wxMenuBar with a wxMenu in it, like so: http://i.imgur.com/Ibw6b.png
I then view the XRC Window and it seems ok: http://i.imgur.com/elEpq.png
Then, I add a tool to the toolbar, like so: http://i.imgur.com/qq0Od.png
The problem shows up when I then check the XRC Window and I see that there is a blank space between the menubar and the toolbar: http://i.imgur.com/jfqGK.png
How can I remove this gap? Thanks.
Normal, default frame toolbar shouldn't be added to the sizer managing the rest of the frame elements because it's already handled by wxFrame itself automatically, so if you just need a toolbar positioned in the standard location (as opposed to having a toolbar in the middle of a window or something like that) you just shouldn't do this. I'm still not sure where does the gap come from but I am pretty sure that it will disappear once you stop adding toolbar to the sizer.

adding custom LISTBOX on dockframe window

I need to add a custom (static) list box which i created using toolbox on a fromview i need to add this listbox on the Dockpaneview (Output window) provided by MFC.
How to add the custom list box on the output window
It is possible to add list box at output window by using Panel control.
then you can what are the controls you need to display on output window.
For example:
To add text box and button;
I hope you will done.