自己封装,布局中间显示
//根据背景色自动计算合适的前景色
double gray = (0.299 * color.red() + 0.587 * color.green() + 0.114 * color.blue()) / 255;
QColor textColor = gray > 0.5 ? Qt::black : Qt::white;
对QTableView或者QTableWidget禁用列拖动。
#if (QT_VERSION <= QT_VERSION_CHECK(5,0,0))
ui->tableView->horizontalHeader()->setResizeMode(0, QHeaderView::Fixed);
#else
ui->tableView->horizontalHeader()->setSectionResizeMode(0, QHeaderView::Fixed);
#endif
我可以给出以下解决方案:
int x = (width() - toolbar->width())/2; int y = (height() - toolbar->height())/2; toolbar->move(x,y);
area->setStyleSheet("background-color:red;");
current->hide(); next->show();
完整代码如下:
// 移动工具栏到界面中间 int x = (width() - toolbar->width())/2; int y = (height() - toolbar->height())/2; toolbar->move(x,y);
// 设置区域的背景颜色为红色 area->setStyleSheet("background-color:red;");
// 切换界面 current->hide(); next->show();